Basic HTML Questions
1. What does HTML stand for?
HTML stands for Hypertext Markup Language. It is the standard language used to create and design documents on the World Wide Web.
2. What is the structure of an HTML document?
An HTML document typically follows a standard structure, which includes the following elements:
1. `` - Declares the document type and version of HTML.
2. `` - Root element that contains all other HTML elements.
3. `` - Contains meta-information about the document, such as the title, character set, and links to stylesheets.
4. `
5. `
Example:
```html
Hello, World!
```
3. What are tags in HTML?
Tags are the building blocks of HTML. They are used to create elements and define the structure of a web page. Tags are usually enclosed in angle brackets. There are two types of tags:
- Opening Tag: Marks the beginning of an element (e.g., `
`).
- Closing Tag: Marks the end of an element (e.g., `
Some tags, known as self-closing or void elements, do not require a closing tag (e.g., `
` or `
4. What is the difference between block-level elements and inline elements?
Block-level elements and inline elements differ in how they are rendered on the page.
- Block-Level Elements: These elements take up the full width available and start on a new line. Examples include `
` to ``, `
`, and ` This is a paragraph.
- Inline Elements: These elements only take up as much width as necessary and do not start on a new line. Examples include ``, ``, ``, and ``.
Intermediate HTML Questions
5. What are attributes in HTML?
Attributes provide additional information about HTML elements. They are specified in the opening tag and consist of a name and a value pair. Common attributes include:
- `id`: A unique identifier for an element.
- `class`: Specifies one or more class names for an element, used for styling.
- `href`: Specifies the URL for links.
- `src`: Specifies the path to an image.
Example:
```html
Visit Example
```
6. What is the purpose of the `` tag?
The `` tag provides metadata about the HTML document. It is placed within the `` section and can include information such as character set, viewport settings, and search engine optimization (SEO) details.
Example:
```html
```
7. Explain the difference between `
The `
- `
- `` tag: An inline element used to group small portions of text or other inline elements without breaking the flow of the document.
Example:
```html
Title
This text is highlighted.
```
Advanced HTML Questions
8. What is the purpose of the `
```
9. What are semantic HTML elements?
Semantic HTML elements clearly describe their meaning in a human- and machine-readable way. These elements enhance accessibility and SEO by providing more context about the content. Examples of semantic elements include:
- `
- `