Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

A simple explanation of how HTML gives structure to every webpage

Updated
•3 min read•View as Markdown
Understanding HTML Tags and Elements

What is HTML and why do we use it?

When you open a website, what you actually see — text, headings, images, buttons — all of that starts with HTML.

HTML stands for HyperText Markup Language.

Think of HTML as the skeleton of a webpage.

  • It gives structure

  • It defines what each piece of content is

  • It tells the browser this is a heading, this is a paragraph, this is an image

Without HTML, a webpage has no structure at all.


What is an HTML tag?

An HTML tag is a label used to mark content.

You can think of a tag like a box label:

  • It tells what type of content is inside

Example:

<p>Hello World</p>

Here:

  • <p> tells the browser this is a paragraph

📌 Diagram to add here: HTML tag vs element breakdown


Opening tag, closing tag, and content

Most HTML tags come in pairs:

<h1>Welcome</h1>

This has three parts:

  1. Opening tag → <h1>

  2. Content → Welcome

  3. Closing tag → </h1>

The opening tag starts the meaning.
The closing tag ends it.
Everything in between is the content.


What does an HTML element mean?

This is where beginners often get confused.

👉 Tag is only the label.
👉 Element is the complete structure.

Example:

<p>Hello</p>
  • <p> → tag

  • </p> → tag

  • <p>Hello</p> → element

An HTML element = opening tag + content + closing tag.

📌 Diagram to add here: HTML element structure breakdown


Self-closing (void) elements

Some elements don’t wrap content.

They exist by themselves.

Examples:

<img />
<br />
<hr />

These are called:

  • Self-closing elements

  • Or void elements

They don’t need a closing tag because there is no content inside.


Block-level vs inline elements

HTML elements behave differently on the page.

Block-level elements

  • Start on a new line

  • Take full width

Examples:

<h1>
<p>
<div>

Think of block elements as full rows.


Inline elements

  • Stay in the same line

  • Take only required space

Examples:

<span>
<a>
<strong>

Think of inline elements as words inside a sentence.

📌 Diagram to add here: Block vs inline element layout


Commonly used HTML tags

Here are some tags you’ll use almost daily:

<h1> to <h6>  <!-- Headings -->
<p>           <!-- Paragraph -->
<div>         <!-- Container -->
<span>        <!-- Inline container -->
<a>           <!-- Link -->
<img>         <!-- Image -->
<ul>, <ol>, <li> <!-- Lists -->

Don’t try to memorize all tags at once.
You’ll learn them naturally by using them.


Tip: Inspect HTML in your browser

One of the best ways to learn HTML is:

  • Right-click on a webpage

  • Click Inspect

  • Look at the HTML structure

You’ll start recognizing:

  • Tags

  • Elements

  • Block vs inline behavior

This builds confidence quickly.


The mental model to remember

  • HTML gives structure

  • Tags label content

  • Elements are complete units

  • Block elements build layout

  • Inline elements decorate content

You don’t need to be perfect.

You just need to understand what HTML is trying to say.