DEV Community

Cover image for Understanding HTML Tags and Elements
Ritam Saha
Ritam Saha

Posted on

Understanding HTML Tags and Elements

Introduction: HTML Is the Skeleton of the Web

Open any website.
Scroll. Click. Read.

It feels smooth, almost effortless—but underneath that smooth experience is something brutally simple: plain text arranged with clear intentions.

Every website that you visit in daily basis—whether it’s Google, YouTube, or even this website where you are reading the blog—all starts with the same foundation: HTML.

Think of a webpage like a human body:

  • HTML is the skeleton (structure)
  • CSS is the skin, the beauty (design)
  • JavaScript is the brain and muscles (behavior/functionality)

Without HTML, there is no structure. No headings. No paragraphs. No buttons.
This blog focuses on how HTML structures content using tags and elements, starting from absolute basics.


What Is HTML and Why Do We Use It?

HTML (HyperText Markup Language) is the standard language used to create and structure content on the web. HTML is a markup language that web browsers use to interpret and compose text, images, and other material into visible or audible web pages. In 1990, physicist Tim Berners-Lee developed HTML for his proposal on Internet-based hypertext system.

HTML tells the browser:

  • What is a heading
  • What is a paragraph
  • What is a button, image, or link

HTML does not:

  • Decide colors
  • Add animations
  • Handle logic

Its sole responsibility is structure and meaning.


What Is an HTML Tag?

An HTML tag is a keyword wrapped inside angle brackets (< >) that tells the browser how to treat content. HTML tags are used to structure and format content of webpages. It tells the browser how to display text, images, links, and other media. In general, they start with <tag> and end with </tag>.

Example:

<p>Hello World</p>
Enter fullscreen mode Exit fullscreen mode

Here:

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

Tags are like labels attached to content. Here are some tags, which are commonly used :

  1. <p></p> - paragraph tag.
  2. <h1></h1> - heading tag.
  3. <table></table> - table tag.
  4. <img/> - image tag.
  5. <br/> - break tag.

But here is a question that should arise in your mind:

There are some tags that are written two times, but some are written only one time. What's actually happening? How to know when to write double and when to write single times?

To understand why some tags appear once and others twice, we need to look at how tags actually wrap content.


Opening tags & Closing tags

In most of the cases, Tags in HTML come in pairs - opening and closing tag. Opening tag is <tag> and closing tag comes with a forward slash </tag>.

Here are few examples :

  • <p>this is a paragraph tag</p>: <p> is an opening tag, </p> is a closing tag and “this is a paragraph tag” is a content of this tag

  • <h1>I am H1</h1>: <h1> is an opening tag, </h1> is a closing tag and “I am H1” is a content of this tag

  • <li>Here are the list of things</li>: <li> is an opening tag, </li> is a closing tag and “Here are the list of things” is a content of this tag

Imagine there's a burger, and opening tag acts as the bottom bread, content as filling and closing tag as top bread. If there's no top bread then the burger keeps leaking everything below.


What Is an HTML Element?

An HTML element is the complete structure:

  • Opening tag
  • Content
  • Closing tag (if any)

So:

<p>This is a paragraph</p>
Enter fullscreen mode Exit fullscreen mode

✔ This entire line is one HTML element

Key Difference (Non-Negotiable Concept):

Term Meaning
Tag the label itself (<p>)
Element opening tag + content + closing tag

This confusion is common—clear it early.

Tags VS Elements


Self-Closing (Void) Elements

Some elements do not wrap content.
They exist alone.

Examples:

<img src="image.jpg"/>
<br/>
<hr/>
Enter fullscreen mode Exit fullscreen mode

These are called Self-closing elements or Void elements.

They:

  • Do not have closing tags
  • Do not contain text content

They represent objects or breaks, not containers.


Block-Level vs Inline Elements

HTML elements behave differently in layout.

Block-Level Elements

  • Take full width
  • Start on a new line
  • Can contain inline elements within it

Examples:

<div></div>
<p></p>
<h1></h1>
<section></section>
<ul></ul>
<ol></ol>
<li></li>
<form></form>
Enter fullscreen mode Exit fullscreen mode

Inline Elements

  • Take only required width
  • Stay in the same line

Examples:

<span></span>
<a></a>
<img></img>
<em></em>
<strong></strong>
Enter fullscreen mode Exit fullscreen mode

Block vs Inline Elements


Commonly Used HTML Tags

Here’s a starter set—no advanced tags yet:

Tag Purpose
<html> Root element that wraps the entire HTML document
<head> Holds metadata and configuration for the webpage
<title> Sets the text shown in the browser tab
<meta> Provides metadata like character set, viewport, or description
<link> Connects external resources like CSS files
<body> Contains all visible content of the webpage
<h1> Main heading (highest importance)
<p> Paragraph of text
<strong> Indicates strong importance (usually bold)
<em> Emphasizes text (usually italic)
<div> Generic block-level container
<header> Introductory section or top area of a page/section
<nav> Contains navigation links
<section> Groups related content into sections
<article> Represents independent, self-contained content
<footer> Footer area for a page or section
<a> Creates a hyperlink
<img> Embeds an image
<ul> Unordered (bulleted) list
<li> List item inside a list
<form> Wraps user input fields
<input> Accepts user input
<button> Clickable button
<table> Creates a table
<tr> Table row
<td> Table data cell
<script> Embeds or links JavaScript

At the very beginning, it might feel a bit overwhelming, but believe me, HTML is not that type of language that can be spoon-fed. So you need to explore by yourself.


Learn by Inspecting HTML in the Browser

One of the fastest learning hacks:

  • Right-click any webpage
  • Click Inspect
  • Observe the HTML structure

This:

  • Builds intuition
  • Shows real-world HTML
  • Connects theory with practice

Treat browser DevTools as your HTML microscope, more than that, as your companion in learning HTML.


Conclusion: HTML Is Learned by Touch, Not Tutorials

HTML is simple—but it is not shallow.

There is no perfect tutorial that can teach you HTML from start to finish, because HTML was never meant to be consumed that way. Trying to “finish HTML” through tutorials alone is exhausting—and honestly, unnecessary.

HTML is learned by seeing, breaking, and exploring.

You learn it when you:

  • Inspect a random website and ask “why is this written like that?”
  • Change a tag and watch the layout break
  • Wrap something in a <div> just to see what happens

This is not a weakness of HTML.
This is its strength.

HTML rewards curiosity. The more you explore, the more it starts to make sense. Over time, tags stop feeling like syntax—and start feeling like meaning.

So don’t aim to memorize HTML.
Aim to get comfortable experimenting with it.

Open DevTools. Read other people’s markup. Build messy pages. Break things.

That’s how HTML is actually learned.


Follow for more beginner-friendly breakdowns of core software engineering concepts.

Top comments (0)