HTML Elements

All HTML Topics

An HTML element is a complete piece of content on a webpage. It is usually made up of an opening tag, some content, and a closing tag.

💡 Think of it this way

Think of an HTML element like a container. The opening tag tells the browser where the container starts, the content goes inside it, and the closing tag tells the browser where it ends.

For example:

<p>Hello World!</p>

The complete <p>Hello World!</p> is an HTML element.

Anatomy of an HTML Element

Let's break one element into its individual parts.

<p>Hello World!</p>
│    │            │
│    │            └── Closing tag
│    └─────────────── Content
└──────────────────── Opening tag
Opening Tag
<p> tells the browser that a paragraph element is starting.
Content
Hello World! is the content placed inside the element.
Closing Tag
</p> tells the browser that the paragraph element has ended.

Common HTML Elements

HTML provides many elements for different types of content.

<h1>Heading</h1>

Creates a main heading.

<p>Paragraph</p>

Creates a paragraph.

<a href="#">Link</a>

Creates a clickable hyperlink.

<button>Click</button>

Creates a button.

<strong>Important</strong>

Gives strong importance to text.

<div>Content</div>

Creates a generic container.

HTML Tag vs HTML Element

These two terms are related, but they are not exactly the same.

Term Example Meaning
Opening Tag <p> Starts the paragraph.
Closing Tag </p> Ends the paragraph.
Element <p>Hello</p> The complete structure.

HTML Elements Can Be Nested

One HTML element can be placed inside another HTML element.

<div>

    <h1>My Website</h1>

    <p>
        Welcome to my website.
    </p>

</div>

Here, the <h1> and <p> elements are inside the <div> element. This is called nesting.

⚠️ Important rule: Always close nested elements in the correct order.

What Are Empty Elements?

Some HTML elements do not contain content and therefore do not need a closing tag.

<br>

Inserts a line break.

<img src="image.jpg" alt="Image">

Embeds an image into the page.

<hr>

Represents a thematic break.

💡 Empty elements are also sometimes called void elements. They do not contain normal content between an opening and closing tag.

Try HTML Elements Yourself

Change the HTML below and click Run to see the result.

index.html
📝 Edit Code
👁 Live Preview
💡 Edit the code on the left and click Run to see your changes instantly.

HTML Elements: Quick Summary

Element
A complete piece of HTML structure.
Opening Tag
Marks where an element begins.
Content
Information placed inside an element.
Closing Tag
Marks where an element ends.
Nesting
Placing one element inside another.
Empty Element
An element that does not contain content.
🎯 Remember: HTML is built from elements. Once you understand elements, tags, nesting, and attributes, the rest of HTML becomes much easier to learn.