HTML Questions:
1. What is HTML?
- HTML stands for HyperText Markup Language. It’s the basic language used to create the structure of web pages by defining elements like headings, paragraphs, links, and more.
2. What are HTML tags?
- HTML tags are keywords surrounded by angle brackets (`< >`). They define how content on a web page should be displayed, like `<p>` for paragraphs or `<h1>` for headings.
3. What is the difference between `<div>` and `<span>`?
- `<div>` is a block-level element that takes up the full width available, used for structuring layouts. `<span>` is an inline element used for styling or marking parts of text without disrupting the flow.
4. What is the purpose of the `alt` attribute in images?
- The `alt` attribute provides a text description of an image, which is helpful for people using screen readers or when the image doesn’t load.
5. What is the difference between block-level and inline elements?
- Block-level elements take up the entire width available (like `<div>`, `<p>`, etc.). Inline elements only take up as much width as needed (like `<span>`, `<a>`, etc.).
6. How do you create a hyperlink in HTML?
- Use the `<a>` tag with the `href` attribute to create a link, like this: `<a href="https://example.com">Click here</a>`.
7. What is a semantic HTML tag?
- Semantic tags clearly describe their purpose, like `<article>`, `<header>`, or `<footer>`. They make your code more readable and SEO-friendly.
8. What is the purpose of the `DOCTYPE` declaration in HTML?
- It tells the browser what version of HTML you’re using, ensuring the page is rendered correctly. For HTML5, it's simply `<!DOCTYPE html>`.
9. What’s the difference between HTML5 and previous versions?
- HTML5 introduced new features like semantic tags (`<article>`, `<section>`), new input types (`email`, `date`), and multimedia support without plugins (`<audio>`, `<video>`).
10. What is the difference between `<meta>` tags and `<title>` tags?
- The `<title>` tag sets the page's title in the browser tab, while `<meta>` tags provide metadata about the page, such as descriptions or keywords for SEO.
11. What is a form in HTML?
- A form is an element (`<form>`) that collects user inputs and submits them to a server. It typically contains input fields like text boxes, checkboxes, and buttons.
12. What are some common attributes of the `<input>` tag?
- Some common attributes are `type`, `name`, `value`, `placeholder`, and `required`.
13. What is the `action` attribute in a form?
- The `action` attribute specifies where the form data should be sent when it’s submitted, usually a URL of a server-side script.
14. What is the difference between `GET` and `POST` methods in forms?
- `GET` appends form data to the URL and is visible in the browser’s address bar. `POST` sends the data in the request body, making it more secure for sensitive information.
15. What is the `<iframe>` tag used for?
- An `<iframe>` is used to embed another HTML document within the current page, like a YouTube video or Google Map.
16. What are HTML attributes?
- Attributes provide additional information about an element. For example, in `<img src="image.jpg" alt="Image">`, `src` and `alt` are attributes.
17. What’s the difference between `<ul>` and `<ol>` tags?
- `<ul>` creates an unordered list with bullet points, while `<ol>` creates an ordered list with numbers.
18. What is the `<em>` tag?
- The `<em>` tag is used to emphasize text. It typically renders text in italics.
19. What is the `<strong>` tag?
- The `<strong>` tag is used to define important text, typically making it bold.
20. What’s the difference between an HTML and XHTML?
- XHTML is a stricter, XML-based version of HTML. It requires elements to be properly closed, attributes to be quoted, and all tags to be lowercase.
21. What is the purpose of the `<head>` tag?
- The `<head>` tag contains metadata and links to stylesheets or scripts. It doesn't affect the visual content of the page directly.
22. Can you nest block-level elements inside inline elements?
- No, block-level elements should not be nested inside inline elements according to HTML standards.
23. What is the purpose of the `<br>` tag?
- The `<br>` tag inserts a line break, moving the text to a new line.
24. What is a favicon?
- A favicon is the small icon that appears in the browser tab, usually created using a `<link>` tag in the `<head>` section.
25. What’s the difference between the `id` and `class` attributes in HTML?
- `id` is unique and should only be used once per page, while `class` can be applied to multiple elements for styling or scripting purposes.
1. What is HTML?
- HTML stands for HyperText Markup Language. It’s the basic language used to create the structure of web pages by defining elements like headings, paragraphs, links, and more.
2. What are HTML tags?
- HTML tags are keywords surrounded by angle brackets (`< >`). They define how content on a web page should be displayed, like `<p>` for paragraphs or `<h1>` for headings.
3. What is the difference between `<div>` and `<span>`?
- `<div>` is a block-level element that takes up the full width available, used for structuring layouts. `<span>` is an inline element used for styling or marking parts of text without disrupting the flow.
4. What is the purpose of the `alt` attribute in images?
- The `alt` attribute provides a text description of an image, which is helpful for people using screen readers or when the image doesn’t load.
5. What is the difference between block-level and inline elements?
- Block-level elements take up the entire width available (like `<div>`, `<p>`, etc.). Inline elements only take up as much width as needed (like `<span>`, `<a>`, etc.).
6. How do you create a hyperlink in HTML?
- Use the `<a>` tag with the `href` attribute to create a link, like this: `<a href="https://example.com">Click here</a>`.
7. What is a semantic HTML tag?
- Semantic tags clearly describe their purpose, like `<article>`, `<header>`, or `<footer>`. They make your code more readable and SEO-friendly.
8. What is the purpose of the `DOCTYPE` declaration in HTML?
- It tells the browser what version of HTML you’re using, ensuring the page is rendered correctly. For HTML5, it's simply `<!DOCTYPE html>`.
9. What’s the difference between HTML5 and previous versions?
- HTML5 introduced new features like semantic tags (`<article>`, `<section>`), new input types (`email`, `date`), and multimedia support without plugins (`<audio>`, `<video>`).
10. What is the difference between `<meta>` tags and `<title>` tags?
- The `<title>` tag sets the page's title in the browser tab, while `<meta>` tags provide metadata about the page, such as descriptions or keywords for SEO.
11. What is a form in HTML?
- A form is an element (`<form>`) that collects user inputs and submits them to a server. It typically contains input fields like text boxes, checkboxes, and buttons.
12. What are some common attributes of the `<input>` tag?
- Some common attributes are `type`, `name`, `value`, `placeholder`, and `required`.
13. What is the `action` attribute in a form?
- The `action` attribute specifies where the form data should be sent when it’s submitted, usually a URL of a server-side script.
14. What is the difference between `GET` and `POST` methods in forms?
- `GET` appends form data to the URL and is visible in the browser’s address bar. `POST` sends the data in the request body, making it more secure for sensitive information.
15. What is the `<iframe>` tag used for?
- An `<iframe>` is used to embed another HTML document within the current page, like a YouTube video or Google Map.
16. What are HTML attributes?
- Attributes provide additional information about an element. For example, in `<img src="image.jpg" alt="Image">`, `src` and `alt` are attributes.
17. What’s the difference between `<ul>` and `<ol>` tags?
- `<ul>` creates an unordered list with bullet points, while `<ol>` creates an ordered list with numbers.
18. What is the `<em>` tag?
- The `<em>` tag is used to emphasize text. It typically renders text in italics.
19. What is the `<strong>` tag?
- The `<strong>` tag is used to define important text, typically making it bold.
20. What’s the difference between an HTML and XHTML?
- XHTML is a stricter, XML-based version of HTML. It requires elements to be properly closed, attributes to be quoted, and all tags to be lowercase.
21. What is the purpose of the `<head>` tag?
- The `<head>` tag contains metadata and links to stylesheets or scripts. It doesn't affect the visual content of the page directly.
22. Can you nest block-level elements inside inline elements?
- No, block-level elements should not be nested inside inline elements according to HTML standards.
23. What is the purpose of the `<br>` tag?
- The `<br>` tag inserts a line break, moving the text to a new line.
24. What is a favicon?
- A favicon is the small icon that appears in the browser tab, usually created using a `<link>` tag in the `<head>` section.
25. What’s the difference between the `id` and `class` attributes in HTML?
- `id` is unique and should only be used once per page, while `class` can be applied to multiple elements for styling or scripting purposes.
Last edited: