HTML – ELEMENTS

An HTML element is the fundamental building block of HTML documents. It defines the structure and content of a webpage. An HTML element typically consists of:
Opening Tag
The starting point of an HTML element, enclosed in angle brackets (< and >), with the element name. Example: <p>, <h1>.
Start Tag | Content | End Tag |
---|---|---|
<p> | This is a paragraph. | </p> |
<h1> | Welcome to My Website | </h1> |
<div> | This is division content. | </div> |
Nested HTML Elements
HTML elements can contain other HTML elements, creating a hierarchy:
<div>
<h1>Main Title</h1>
<p>This is a paragraph inside a div element.</p>
</div>
Self-Closing Elements
Some elements do not contain content and are self-closing. These include:
*<br> : Inserts a line break.
*<img> : Embeds an image.
*<hr> : Inserts a horizontal line.
<img src="example.jpg" alt="An example image">
<br>
<hr>
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nonbreaking Spaces</title>
</head>
<body>
<title>Nested Elements Example</title>
</head>
<body>
<h1>Start on a new line and take up <i> the full width </i> of their container. </h1>
<p>This is <u>underlined</u> paragraph</p>
</body>
</html>
</body>
</html>
This will produce the following result:
