Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
4 min read
Understanding HTML Tags and Elements

Understanding HTML Tags and Elements: A Beginner's Guide

So you want to build websites? Same here! I recently started my web development journey, and the first thing I had to wrap my head around was HTML. Let me share what I've learned so far—hopefully, it saves you some confusion.


What Even Is HTML?

HTML stands for HyperText Markup Language. Fancy name, simple job.

Think of a webpage like a human body. HTML is the skeleton—it gives structure to everything you see. Without it, your content would just be a messy blob of text floating in the void. CSS makes it pretty, JavaScript makes it interactive, but HTML? HTML holds it all together.

Every website you've ever visited—Google, YouTube, that random recipe blog—is built on HTML at its core.


Tags: The Building Blocks

Here's where things clicked for me. An HTML tag is basically a label that tells the browser, "Hey, treat this content in a specific way."

Tags look like this: <tagname>

They come in pairs—an opening tag and a closing tag:

<p>This is a paragraph.</p>
  • <p> → Opening tag (starts the party)

  • </p> → Closing tag (ends the party, notice the /)

  • This is a paragraph. → Content (the actual party)

I like to think of it as a box. The opening tag opens the box, you put stuff inside, and the closing tag seals it shut.


Tag vs Element: What's the Difference?

This confused me at first, so let me clear it up:

┌─────────────────────────────────────────┐
│            HTML ELEMENT                 │
│                                         │
│   <h1>    Hello World!    </h1>         │
│    ↑           ↑            ↑           │
│ Opening     Content      Closing        │
│   Tag                      Tag          │
└─────────────────────────────────────────┘
  • Tag = Just the <h1> or </h1> part

  • Element = The whole package (opening tag + content + closing tag)

So when someone says "the paragraph element," they mean everything: <p>content here</p>.


Self-Closing (Void) Elements

Some elements are loners—they don't need a closing tag because they don't hold content.

<img src="cat.jpg" alt="A cute cat">
<br>
<hr>
<input type="text">

These are called void elements or self-closing elements. No closing tag needed. They just do their thing and move on.


Block-Level vs Inline Elements

This one's important for understanding how stuff appears on your page.

Block-level elements:

  • Take up the full width available

  • Start on a new line

  • Examples: <div>, <p>, <h1>, <section>

Inline elements:

  • Only take up as much width as needed

  • Don't break the flow—they sit next to each other

  • Examples: <span>, <a>, <strong>, <em>

Here's a visual:

┌──────────────────────────────────────┐
│ <div> I take the whole row </div>    │  ← Block
└──────────────────────────────────────┘
┌──────────────────────────────────────┐
│ <p> Me too! </p>                     │  ← Block
└──────────────────────────────────────┘

┌────────┐┌────────┐┌────────┐
│ <span> ││ <span> ││ <span> │         ← Inline (side by side)
└────────┘└────────┘└────────┘

Commonly Used HTML Tags

Here are the ones you'll use all the time:

TagPurpose
<h1> to <h6>Headings (h1 is biggest)
<p>Paragraphs
<a>Links
<img>Images
<div>Generic container (block)
<span>Generic container (inline)
<ul>, <ol>, <li>Lists
<strong>Bold text
<em>Italic text

Quick Tip: Inspect Everything!

Here's something that accelerated my learning—right-click on any webpage and hit "Inspect". You'll see the actual HTML structure. It's like peeking behind the curtain. I spent hours just exploring how my favorite websites are built.


Wrapping Up

HTML isn't complicated once you get the basics down. Remember:

  • HTML = Structure of your webpage

  • Tags = Labels that define content

  • Elements = Tags + the content inside them

  • Some elements close themselves

  • Block elements hog the row, inline elements share

Start small. Build a simple page with a heading, a paragraph, and maybe a link. Then keep adding. That's how we all learn.

Happy coding! 🚀


This article is part of my learning journey in Web Dev Cohort 2026. If you're also learning, let's connect!