HTML_interview
HTML_interview
1. What is HTML?
Ordered List (<ol>): A list of items with a defined sequence, typically numbered.
Definition List (<dl>): A list of terms and their descriptions, often used for
glossaries or metadata.
Answer:
id: Used to uniquely identify an element. Each id must be unique within a page,
meaning no two elements can share the same id.
class: Used to classify multiple elements under the same category. Multiple
elements can share the same class, and an element can have multiple classes.
Answer:
Answer:
Semantic HTML elements clearly describe their meaning to both the browser and
the developer. Examples include:
Answer:
Inline elements: Do not start on a new line and only take up as much width as
needed (e.g., <span>, <a>).
Block elements: Always start on a new line and take up the full width available
(e.g., <div>, <p>).
Inline-block elements: Behave like inline elements but allow setting of height and
width (e.g., <img>).
Answer:
The alt attribute provides alternative text for an image if the image cannot be
displayed. It is essential for accessibility as screen readers read the alt text to
visually impaired users.
Answer:
The <!DOCTYPE> declaration is used to define the document type and version of
HTML used in the document. In HTML5, it is written as:
<!DOCTYPE html>
Answer:
Answer:
You can embed a video using the <video> tag. For example:
<video controls>
<source src="movie.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
The controls attribute adds playback controls like play, pause, and volume.
Answer:
The <meta> tag provides metadata about the HTML document, such as character
set, author, and page description. Metadata is not displayed on the page but is
used by browsers, search engines, and other web services.
Example:
<meta charset="UTF-8">
<meta name="description" content="A guide to HTML interview questions.">
12. What is the difference between GET and POST methods in forms?
Answer:
GET: Appends form data to the URL as query parameters. This method is less
secure and should not be used for sensitive data.
POST: Sends form data in the HTTP request body, making it more secure and
suitable for sensitive information.
Answer: Data attributes allow you to store custom data in HTML elements. They
are defined using the data- prefix.
Example:
Answer:
The <iframe> tag is used to embed another HTML page within the current page.
It is commonly used to embed YouTube videos, Google Maps, or other web
content. Example:
localStorage: Stores data with no expiration time. Data persists even after the
browser is closed.
sessionStorage: Stores data for the duration of the page session (data is lost
when the page is closed).