An HTML element is the basic building block of a web page.
It tells the browser how to display content such as text, images, links, and more.
Each element usually has:
An opening tag — tells where the element begins
Content — what’s inside the element
A closing tag — tells where the element ends
<tagname>Content goes here</tagname>
<tagname> → opening tag
Content goes here → element content
</tagname> → closing tag
<p>This is a paragraph element.</p>
This is a paragraph element.
Elements can be placed inside other elements — this is called nesting.
<p>This is a <b>bold</b> word inside a paragraph.</p>
This is a bold word inside a paragraph.
Some HTML elements don’t have closing tags. These are called empty elements or self-closing tags.
<br> <!-- Line break -->
<hr> <!-- Horizontal line -->
<img src="image.jpg" alt="Sample image">
<p>Learn HTML<br>Step by Step</p>
<hr>
<div>
<p>Hello <b>World</b>!</p>
</div>
<img src="logo.png" alt="Website Logo">
<br>
<hr>
| Type | Description | Example Tags |
|---|---|---|
| Block-level | Start on a new line and take full width | <div>, <p>, <h1>, <section>, <article> |
| Inline | Stay inline with text and only take as much width as needed | <span>, <a>, <b>, <i>, <img> |
<p>This is a block-level paragraph.</p>
<a href="#">This is an inline link</a>
Every HTML page forms a tree-like structure (called the DOM Document Object Model).
<html>
<body>
<h1>Welcome</h1>
<p>This is a <b>sample</b> paragraph.</p>
</body>
</html>