Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
•4 min read•View as Markdown

Let’s start with something very simple.

Imagine you want to build a human body.

What do you need first?

👉 Skeleton

Before skin, before clothes, before makeup — you need a skeleton.

That’s exactly what HTML is for a website.


🧠 What is HTML and Why Do We Use It?

HTML stands for HyperText Markup Language.

Big name. Simple job.

HTML is:

The skeleton of a webpage

HTML tells the browser:

  • This is a heading

  • This is a paragraph

  • This is a button

  • This is an image

Without HTML:

  • No structure

  • No content

  • Nothing to show

CSS adds beauty 💄
JavaScript adds behavior 🧠
But HTML gives structure 🦴


🏷️ What is an HTML Tag?

An HTML tag is like a label or instruction.

It tells the browser:

“Hey browser, treat this content in a special way.”

Example:

<p>Hello</p>

Here:

  • <p> tells the browser: “This is a paragraph”

  • </p> tells the browser: “Paragraph ends here”

So a tag is basically:

A word wrapped inside < >


🔓 Opening Tag, Closing Tag, and Content

Let’s break one simple example:

<h1>Hello World</h1>

This has three parts:

  1. Opening tag → <h1>

  2. Content → Hello World

  3. Closing tag → </h1>

Think of it like a box 📦

[ Opening tag | content | closing tag ]

The opening tag opens the box
The closing tag closes the box
The content stays inside


🧩 What is an HTML Element? (Very Important!)

This is where many beginners get confused.

👉 Tag ≠ Element

An HTML element is the complete thing.

That means:

  • Opening tag

  • Content

  • Closing tag

All together.

Example:

<p>I love HTML</p>

This entire line is one HTML element.

So remember this golden rule 🟡:

Tag = part
Element = full structure


📦 Tag vs Element (Super Simple Difference)

ThingMeaning
TagJust the label (<p>)
ElementTag + content + closing tag

If HTML is a sentence:

  • Tag = punctuation

  • Element = full sentence


✂️ Self-Closing (Void) Elements

Some HTML elements don’t have content.

So they don’t need a closing tag.

Example:

<img src="cat.jpg">
<br>
<hr>

These are called:

Self-closing or void elements

Why?

Because:

  • An image doesn’t wrap text

  • A line break has no content

  • A horizontal line has no text

They just exist.


🧱 Block-Level Elements (Big Boxes)

Block elements behave like big boxes.

They:

  • Start on a new line

  • Take full width

  • Stack vertically

Examples:

<div></div>
<p></p>
<h1></h1>
<section></section>

Think of block elements as:

Big LEGO blocks 🧱

Each one sits on its own line.


🧵 Inline Elements (Small Pieces)

Inline elements are smaller.

They:

  • Stay in the same line

  • Take only needed space

  • Sit next to each other

Examples:

<span></span>
<a></a>
<strong></strong>
<em></em>

Think of inline elements as:

Words in a sentence ✏️

They don’t break the line.


🔍 Block vs Inline (Visual Thinking)

Imagine writing a sentence:

Hello my name is Alex
  • Paragraph (<p>) → new line

  • Heading (<h1>) → new line

  • Span (<span>) → stays inside line

That’s the key difference.


⭐ Commonly Used HTML Tags (Beginner Level)

Let’s look at the most important ones.

Headings

<h1>Main title</h1>
<h2>Sub title</h2>

Used for titles and importance.


Paragraph

<p>This is a paragraph</p>

Used for text.


Div (Container)

<div>Content</div>

Used to group things together.

Think of it as a box.


Span (Inline container)

<span>word</span>

Used to style or wrap small text.


Image

<img src="image.jpg">

Shows an image.


<a href="https://example.com">Go</a>

Used for navigation.


🧠 Why HTML is Called the Skeleton

Because HTML:

  • Decides what exists on the page

  • Decides order

  • Decides hierarchy

CSS only styles what HTML creates.
JS only controls what HTML creates.

No HTML = nothing.


🕵️ Inspecting HTML in the Browser

Right-click any webpage → Inspect.

You’ll see:

  • HTML elements

  • Nested structure

  • Tags inside tags

This is how:

  • Professionals learn

  • Beginners improve fast

Don’t memorize tags.
Observe real websites.


🧩 HTML Structure is Like Boxes Inside Boxes

HTML works like this:

<div>
  <h1>Title</h1>
  <p>Text</p>
</div>

Boxes inside boxes inside boxes.

That’s how layout is formed.