Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
4 min read

If you’ve ever looked at a webpage and wondered, “How does the browser know what’s a heading, what’s a paragraph, and what’s just decoration?” that’s where HTML comes in.

HTML is the skeleton of a webpage. Not the colors, not the animations, not the logic. Just the structure.

Without HTML, a webpage would be like a book with no chapters, no paragraphs, and no headings just a long, unreadable stream of text.

What Is HTML?

HTML stands for HyperText Markup Language.

That sounds intimidating, but the idea is simple:

HTML is a way to describe the structure and meaning of content.

It tells the browser:

  • “This is a heading”

  • “This is a paragraph”

  • “This is a button”

  • “This is a container holding other things”

HTML doesn’t decide how pretty things look.
It decides what things are.

HTML Uses Tags

HTML works using tags.

A tag is like a label wrapped around content, telling the browser what that content represents.

Here’s a simple one:

<p>Hello, world</p>

This tells the browser:

“The text ‘Hello, world’ is a paragraph.”

Opening Tag, Content, Closing Tag

Most HTML tags come in pairs.

<p>      Hello, world      </p>
 ^           ^              ^
Opening    Content        Closing
Tag                        Tag
  • Opening tag: <p>

  • Content: Hello, world

  • Closing tag: </p>

The closing tag looks the same as the opening tag, but with a / added.

Tag vs Element

This distinction matters more than it seems.

A tag is just the label

Example:

<p>
</p>

An element is the whole thing

Opening tag + content + closing tag

<p>Hello, world</p>

So:

  • <p> → tag

  • <p>Hello, world</p> → element

If that felt subtle, that’s normal. Most people mix the words early on. Over time, it clicks.

HTML as Boxes Inside Boxes

One of the best ways to think about HTML is as boxes inside other boxes.

<div>
  <h1>Title</h1>
  <p>Some text</p>
</div>

HTML is mostly about nesting elements living inside other elements.

Self-Closing (Void) Elements

Not all elements wrap content. Some elements exist on their own. These are called void elements (or self-closing elements).

Examples:

<img>
<br>
<input>

They don’t have closing tags because there’s nothing inside them.

For example:

<img src="cat.jpg">

This element doesn’t contain content it represents something.

Block-Level vs Inline Elements

This is one of the most important layout ideas in HTML.

Block-Level Elements

  • Start on a new line

  • Take up the full width available

Examples:

  • <div>

  • <p>

  • <h1> to <h6>

Visual idea:

[ Block Element ]
[ Another Block ]
[ Yet Another  ]

Inline Elements

  • Stay within a line

  • Only take up as much space as needed

Examples:

  • <span>

  • <a>

  • <strong>

Visual idea:

Text [inline] more text [inline]

div vs span

These two do almost nothing by themselves and that’s the point.

<div>This is a div</div>
<span>This is a span</span>
  • div → block-level container

  • span → inline container

Think of:

  • div as a box

  • span as a highlighter inside text

Common HTML Tags You’ll See Everywhere

You don’t need to learn every tag at once. These cover most beginner needs:

  • <h1> to <h6> → headings

  • <p> → paragraph

  • <div> → block container

  • <span> → inline container

  • <a> → link

  • <img> → image

  • <ul> / <li> → lists

If you understand what these mean, you’re already ahead.

A Small But Powerful Habit: Inspect the Page

One of the best ways to learn HTML is to inspect real websites.

Right-click any page → Inspect → look at the HTML.

You’ll start noticing:

  • Everything is nested

  • Everything is boxes

  • Even complex sites are built from simple elements

This is how HTML stops feeling abstract.

To Sum Up:

HTML isn’t about memorizing tags. It’s about learning how to describe structure clearly.

Once you see HTML as a skeleton not a styling tool everything else (CSS, JavaScript, frameworks) makes much more sense.