Skip to main content
Madhukar
All Articles

Understanding HTML Tags and Elements

August 24, 20266 min read
beginnerhtmlfrontendweb-developmentcss
Understanding HTML Tags and Elements

HTML is the skeleton of a webpage

Every webpage you’ve ever visited has a skeleton holding it together — a structure defining what’s a heading, what’s a paragraph, what’s a button, what’s an image. That skeleton is HTML (HyperText Markup Language). It doesn’t make a page look pretty (that’s CSS’s job) — it defines the actual structure and meaning of the content: this is a title, this is a list, this is a link. Without HTML, a browser would have no idea how to organize or display anything at all.

What an HTML Tag Is

A tag is a keyword wrapped in angle brackets, marking the start or end of a piece of content:

<p>

This is an opening tag — it tells the browser “a paragraph starts here.” Tags are the individual building blocks HTML uses to label different pieces of content.

Opening Tag, Closing Tag, and Content

Most HTML tags come in pairs — an opening tag, some content, and a matching closing tag (marked with a forward slash):

<p>Hello, world!</p>

Breaking this down:

  • <p> — the opening tag, marking where the paragraph begins
  • Hello, world! — the content, the actual text (or other elements) inside
  • </p> — the closing tag, marking where the paragraph ends

What an HTML Element Means

Here’s the distinction that trips up a lot of beginners: the tag is just the label (<p> or </p>) — the element is the entire thing together: opening tag, content, and closing tag, as one complete unit.

<p>Hello, world!</p>

The whole line above is one element. <p> and </p> are its two tags. Saying "the <p> tag" when you mean the whole thing is extremely common in casual conversation — but understanding the precise difference makes documentation, and conversations with other developers, much clearer.

A useful analogy: think of a tag like a single label on a box, and an element like the entire labeled, packed box — the label alone isn’t the box; it’s just one part identifying what’s inside.

Self-Closing (Void) Elements

Not every element wraps around content. Some tags represent something complete on their own, with nothing to “close” — these are called void elements, and they don’t use a separate closing tag at all.

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

<img> doesn't wrap around content — it is the content (an image). <br> simply inserts a line break — there's nothing to put "inside" it. These elements are self-contained, so requiring a closing tag wouldn't make sense.

Block-Level vs Inline Elements

HTML elements generally fall into two layout categories, and understanding the difference explains a lot about how a page’s structure actually behaves visually.

Block-level elements

A block-level element takes up the full width available, and always starts on a new line — pushing whatever comes after it down to the next line too.

<div>This div takes up the whole line.</div>
<p>So does this paragraph.</p>

Common block-level elements: <div>, <p>, <h1>–<h6>, <ul>, <section>.

Inline elements

An inline element only takes up as much width as its content needs, and sits within the normal flow of text, without forcing a new line.

<p>This sentence has an <span>inline element</span> right in the middle of it.</p>

Common inline elements: <span>, <a>, <strong>, <em>.

Seeing the difference visually

<div>Block element 1</div>
<div>Block element 2</div>
<!-- These stack, each on its own line -->

<span>Inline 1</span> <span>Inline 2</span>
<!-- These sit side by side, in the same line -->

Commonly Used HTML Tags

A small set of tags covers the overwhelming majority of everyday HTML:

<h1>Main Heading</h1>
<h2>Subheading</h2>

<p>A paragraph of text.</p>

<div>A generic block-level container.</div>
<span>A generic inline container.</span>

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

<img src="photo.jpg" alt="Description of the photo">

<ul>
<li>List item one</li>
<li>List item two</li>
</ul>

<button>Click me</button>

A genuinely useful habit as a beginner: right-click any webpage and choose “Inspect” (or press F12) to open your browser’s developer tools — you can see the exact HTML structure behind any real page, tag by tag, which is one of the fastest ways to build real intuition for how these elements are actually used together.

Final Takeaway

HTML tags are simply labels marking where a piece of content begins and ends; an element is the complete package — opening tag, content, and closing tag together. Void elements skip the closing tag entirely because there’s nothing to wrap. And whether an element behaves as block-level (claiming the full line) or inline (sitting within the text) shapes a huge amount of how a page’s layout naturally behaves, even before any CSS gets involved. Once these fundamentals feel solid, reading — and writing — real HTML stops feeling like memorizing arbitrary syntax, and starts feeling like structuring content the way it’s actually meant to be organized.

Frequently Asked Questions

Is it a mistake to say “the div tag” when I mean “the div element”?

> Not a serious one — it’s extremely common casual shorthand, and most developers understand exactly what you mean. Knowing the precise distinction (tag vs. element) mainly helps when reading more formal documentation, or when the distinction actually matters for a specific technical point.

Do all HTML elements need both an opening and closing tag?

> No — void elements like <img>, <br>, and <input> are self-contained and don't use a separate closing tag, since there's no content for them to wrap around.

Can a block-level element contain inline elements, and vice versa?

> A block-level element can generally contain inline elements (a <p> containing a <span>, for instance) — that's extremely common. Inline elements generally shouldn't contain block-level elements, since that would conflict with how inline elements are meant to sit within a line of text.

What’s the easiest way to start recognizing HTML elements on real websites?

> Use your browser’s “Inspect” tool (right-click any element, or press F12) — it shows you the exact HTML behind any webpage, letting you see real-world tags and elements in context, which builds intuition far faster than examples alone.

Originally published by Mr Madhukar

Read the complete article on Medium with full formatting & reader responses.