HTML elements are the building blocks of an HTML document. They define the structure and content of a web page. Here is a comprehensive guide to the most common HTML elements:
1. Basic Elements
<!DOCTYPE html>: Declares the document type and version of HTML.
<html>: The root element of an HTML document.
<head>: Contains meta-information about the document.
<title>: Sets the title of the document, shown in the browser’s title bar or tab.
<body>: Contains the content of the HTML document.
2. Text Elements
<h1> to <h6>: Headings, with <h1> being the highest (most important) and <h6> the lowest (least important).
<p>: Defines a paragraph.
<br>: Inserts a line break.
<hr>: Defines a thematic break (horizontal rule).
3. Formatting Elements
<b>: Bold text.
<strong>: Important text (typically rendered as bold).
<i>: Italic text.
<em>: Emphasized text (typically rendered as italic).
<mark>: Marked/highlighted text.
<small>: Smaller text.
<del>: Deleted (strikethrough) text.
<ins>: Inserted (underlined) text.
<sub>: Subscript text.
<sup>: Superscript text
4. Lists
<ul>: Unordered list (bulleted).
<ol>: Ordered list (numbered).
<li>: List item.
<dl>: Description list.
<dt>: Term in a description list.
<dd>: Description of the term in a description list.
5. Links
<a>: Anchor (hyperlink). The href attribute specifies the URL of the page the link goes to.
<a href="https://www.example.com">Visit Example</a>
6. Images
<img>: Embeds an image. The src attribute specifies the path to the image, and the alt attribute provides alternative text.
<img src="image.jpg" alt="Description of image">
7. Tables
<table>: Defines a table.
<tr>: Table row.
<th>: Table header cell.
<td>: Table data cell.
<caption>: Table caption.
<table>
<caption>Table Title</caption>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</table>
Java Elements – Objective Questions (MCQs)
Q1. What is an HTML element?
Q2. Which of the following is a self-closing HTML element?
Q3. How many main parts does a standard HTML element have?
Q4. Which element is used to create a hyperlink in HTML?
Q5. Which of the following is TRUE about HTML elements?