Basic HTML Elements Explained: Essential Tags, Examples & Usage

1. What is HTML?

Q: What is HTML?

HTML (HyperText Markup Language) is the standard markup language for creating web pages. It structures content using elements and tags, enabling browsers to render text, images, links, and multimedia.

2. What are HTML elements?

Q: What are HTML elements?

HTML elements are the building blocks of an HTML document, consisting of a start tag, content, and an end tag. For example: <p>This is a paragraph.</p>.

3. What is the purpose of the <head> element?

Q: What is the purpose of the <head> element?

The <head> element contains metadata about the document, such as the title, character encoding, and links to stylesheets or scripts, which are not displayed on the webpage.

4. What does the <title> tag do?

Q: What does the <title> tag do?

The <title> tag defines the document’s title, displayed in the browser’s title bar or tab, and is critical for SEO and navigation.

5. What is the function of the <body> element?

Q: What is the function of the <body> element?

The <body> element contains all visible webpage content, such as text, images, links, and multimedia, that users interact with.

6. How do you create a hyperlink in HTML?

Q: How do you create a hyperlink in HTML?

A hyperlink is created using the <a> tag with the href attribute specifying the URL. Example:

<a href="https://www.example.com">Visit Example</a>

7. What is the purpose of the <img> tag?

Q: What is the purpose of the <img> tag?

The <img> tag embeds images in a webpage, requiring src for the image source and alt for accessibility. Example:

<img src="image.jpg" alt="Description of image">

8. How do you create a list in HTML?

Q: How do you create a list in HTML?

HTML supports ordered lists (<ol>) and unordered lists (<ul>), with items defined by <li>. Example:

<ul>
  <li>Item 1</li>
  <li>Item 2</li>
</ul>

9. What is the difference between <div> and <span>?

Q: What is the difference between <div> and <span>?

<div> is a block-level container for grouping larger content sections, while <span> is an inline container for styling small text portions without breaking content flow.

10. How do you create a table in HTML?

Q: How do you create a table in HTML?

A table is created using <table>, with rows (<tr>), headers (<th>), and data cells (<td>). Example:

<table>
  <tr>
    <th>Header 1</th>
    <th>Header 2</th>
  </tr>
  <tr>
    <td>Data 1</td>
    <td>Data 2</td>
  </tr>
</table>

11. What is the purpose of the <form> element?

Q: What is the purpose of the <form> element?

The <form> element collects user input, including text fields, checkboxes, radio buttons, and submit buttons, for submission to a server.

12. How do you include a CSS file in an HTML document?

Q: How do you include a CSS file in an HTML document?

A CSS file is linked in the <head> section using the <link> tag. Example:

<link rel="stylesheet" href="styles.css">

13. What is the <meta> tag used for?

Q: What is the <meta> tag used for?

The <meta> tag provides metadata like character set, author, or viewport settings, placed in the <head> for SEO and rendering.

14. How do you create a comment in HTML?

Q: How do you create a comment in HTML?

Comments are created using <!-- Comment text here -->, which are not displayed in the browser and are used for code notes.

15. What is the <header> element?

Q: What is the <header> element?

The <header> element represents introductory content or navigation, often containing headings, logos, or links, typically at the top of a page or section.