An HTML element is the building block of every web page. Understanding elements is fundamental — everything in HTML is an element.
An HTML element is defined by a start tag, some content, and an end tag:
<tagname> Content goes here... </tagname>
Examples:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
<a href="https://example.com">Visit Example</a>
| Start Tag | Content | End Tag |
|---|---|---|
<h1> |
My First Heading | </h1> |
<p> |
My first paragraph. | </p> |
<a href="..."> |
Visit Example | </a> |
HTML elements can be nested — meaning elements can contain other elements. Every HTML document is a nest of elements inside elements.
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Here:
<html> element is the root — it contains all other elements<body> element is inside <html><h1> and <p> elements are inside <body><b><i>text</b></i> — Right: <b><i>text</i></b>
Some HTML elements have no content and no end tag. These are called empty elements or void elements.
<br>
<hr>
<img src="photo.jpg" alt="Photo">
<input type="text">
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
| Empty Element | Purpose |
|---|---|
<br> | Line break |
<hr> | Horizontal rule / divider |
<img> | Embed an image |
<input> | Form input field |
<meta> | Page metadata |
<link> | Link external resource (e.g. CSS) |
HTML tags are not case sensitive. <P> means the same as <p>, and <H1> means the same as <h1>.
<P>This is valid.</P>
<p>This is also valid.</p>
Some browsers may still display HTML correctly even if you forget end tags — but never rely on this. Missing end tags can cause unexpected errors.
<!-- Wrong (end tag missing) -->
<p>This is a paragraph.
<p>This is another paragraph.
<!-- Correct -->
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
| Element | Description |
|---|---|
<html> | Root element of the page |
<head> | Contains meta information |
<title> | Page title shown in the browser tab |
<body> | Contains visible page content |
<h1> – <h6> | Headings (h1 = largest, h6 = smallest) |
<p> | Paragraph |
<a> | Hyperlink |
<img> | Image |
<ul> / <ol> | Unordered / Ordered list |
<li> | List item |
<table> | Table |
<div> | Block-level container |
<span> | Inline container |
<br> | Line break (empty element) |
<hr> | Horizontal line (empty element) |
<strong> | Bold / important text |
<em> | Italic / emphasized text |