Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
5 min read
Understanding HTML Tags and Elements

When you open any website, what you see on the screen is designed using many technologies. But the basic structure of every webpage is made using HTML.

If a website was a human body, then:

  • HTML would be the skeleton

  • CSS would be the clothes

  • JavaScript would be the brain and muscles

So before learning anything else in web development, understanding HTML tags and elements is very important.

In this blog, I will explain HTML in a very simple and practical way, just like a student explaining to another student.

What is HTML and Why We Use It

HTML stands for HyperText Markup Language.

Simple meaning:

HTML is the language used to create the structure of a webpage.

HTML tells the browser:

  • This is a heading

  • This is a paragraph

  • This is an image

  • This is a button

  • This is a link

Without HTML, a webpage would have no structure. It would just be plain text with no proper layout.

So we use HTML to:

  • Build the basic layout of websites

  • Organize content

  • Tell browsers how to show text and media

HTML is the foundation of every website.


What is an HTML Tag

An HTML tag is a special keyword written inside angle brackets.

For example:

<p>

This is a tag.

Tags tell the browser what type of content it is.

Think of a tag like a label on a box.

If a box has a label “Books”, you know what is inside.
If a tag is <p>, the browser knows it is a paragraph.

Examples of common tags:

  • <p> for paragraph

  • <h1> for heading

  • <div> for container

  • <span> for small inline text


Opening Tag, Closing Tag, and Content

Most HTML tags come in pairs.

Example:

<p>Hello World</p>

This has three parts:

  • Opening tag: <p>

  • Content: Hello World

  • Closing tag: </p>

The closing tag has a slash to tell the browser where the content ends.

You can think of it like a sentence inside a box:

  • The opening tag opens the box

  • The content goes inside

  • The closing tag closes the box

This helps the browser understand where one piece of content starts and ends.


What is an HTML Element (Very Important)

This is a common beginner confusion.

Tag vs Element

  • Tag is just the opening or closing part

  • Element is the complete thing

So this is an element:

<p>Hello World</p>

The full paragraph, including opening tag, content, and closing tag, is called an HTML element.

Simple rule:

  • <p> is a tag

  • <p>Hello World</p> is an element

Understanding this difference is very important for learning HTML properly.


Self-Closing (Void) Elements

Some HTML elements do not have closing tags.

These are called self-closing or void elements.

Examples:

<img>
<br>
<hr>
<input>

These elements:

  • Do not wrap content

  • Do not have closing tags

  • Just perform a single job

For example:

  • <img> shows an image

  • <br> creates a line break

  • <input> creates a form input

You cannot put text inside these elements.


Block-Level vs Inline Elements

This is a very important layout concept in HTML.


Block-Level Elements

Block-level elements take the full width of the page.

They usually start on a new line.

Examples:

  • <div>

  • <p>

  • <h1> to <h6>

  • <section>

If you add two block elements, they appear one below the other.

Block elements are used to build the main structure of a page.


Inline Elements

Inline elements take only the space they need.

They stay in the same line as other text.

Examples:

  • <span>

  • <a>

  • <strong>

  • <em>

Inline elements are used to style or mark small parts of text inside a line.


Commonly Used HTML Tags

Here are some tags you will use almost daily:

Text and Structure

  • <h1> to <h6> for headings

  • <p> for paragraphs

  • <div> for grouping content

  • <span> for small inline text


  • <a> for links

  • <img> for images


Lists

  • <ul> for unordered list

  • <ol> for ordered list

  • <li> for list items


Forms (Basic)

  • <input> for input fields

  • <button> for buttons

  • <label> for labels

These tags are enough to build many simple web pages.


HTML is Like Building with Boxes

A very easy way to think about HTML is:

HTML is just boxes inside boxes.

For example:

  • A div can contain a paragraph

  • A paragraph can contain a span

  • A section can contain many divs

This box thinking helps you understand layout and nesting.


Try Inspecting HTML in Your Browser

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

You can:

  • Right-click on any webpage

  • Click “Inspect”

  • See the HTML structure

This helps you see how real websites are built.

It is like opening the cover of a machine to see how it works.


My Final Words

HTML is simple, but it is very powerful.

Once you understand:

  • What a tag is

  • What an element is

  • How opening and closing tags work

  • Block vs inline elements

You will feel much more confident in web development.

HTML is the first step in your frontend journey. If you build a strong base here, learning CSS, JavaScript, and frameworks will become much easier.

Think of HTML as the language that teaches your browser how to build a webpage. Once you speak this language well, you can create anything on the web.