Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

HTML Tags and Elements Explained

Published
4 min read
Understanding HTML Tags and Elements
A

Hi, I’m Abdul Samad. A web development learner and tech enthusiast. I write about what I learn, share practical coding tips, and publish in-depth blogs on programming and modern web development.

Check out my full collection of blogs on Hashnode: https://abdulsamad30.hashnode.dev/

Connect with me on X for quick updates and insights: @abdul_sama60108

HTML Basics Explained Simply

HTML is the skeleton of a webpage

HTML stands for HyperText Markup Language.

HTML is not a programming language.

It does not think or calculate.

Its job is simple.

HTML structures content.

If a website were a human body:

  • HTML = skeleton

  • CSS = clothes and style

  • JavaScript = brain and movement

Without HTML, a webpage has no shape.

HTML tells the browser:

  • This is a heading

  • This is a paragraph

  • This is an image

  • This is a button

That is it.


What is an HTML tag

An HTML tag is a label that tells the browser what something is.

Think of tags like labels on boxes.

Example:

<p>Hello world</p>

Here:

  • <p> tells the browser this is a paragraph

Tags are written inside angle brackets < >.

Most tags come in pairs.


Opening tag, closing tag, and content

Most HTML tags have three parts.

Example:

<p>Hello world</p>

1. Opening tag

<p>

This tells the browser where the paragraph starts.

2. Content

Hello world

This is the actual text or content.

3. Closing tag

</p>

This tells the browser where the paragraph ends.

The slash / is important.

Without it, the browser gets confused.


What is an HTML element

This part is important. Many beginners get confused here.

Tag vs Element

  • Tag = just the label

  • Element = opening tag + content + closing tag

Example:

<p>Hello world</p>
  • <p> is a tag

  • </p> is a tag

  • The whole thing together is an HTML element

So remember this:

An HTML element is a complete structure, not just a tag.


Self-closing or void elements

Some elements do not need a closing tag.

Why?

Because they do not wrap content.

Examples:

<imgsrc="photo.jpg">
<br>
<hr>
<input>

These are called:

  • Self-closing elements

  • Void elements

They exist just to do one job, not hold text.

Example:

<imgsrc="cat.png">

An image does not have content inside it.

So no closing tag is needed.


Block-level vs inline elements

This affects layout.

Block-level elements

Block elements:

  • Start on a new line

  • Take full width by default

Examples:

<h1>
<p>
<div>

Example:

<p>This is a paragraph</p>
<p>This is another paragraph</p>

These appear one below the other.

Think of block elements as big boxes.


Inline elements

Inline elements:

  • Stay in the same line

  • Take only as much space as needed

Examples:

<span>
<a>
<strong>

Example:

<p>Hello<span>world</span></p>

The word world stays inside the same line.

Think of inline elements as words inside a sentence.


Commonly used HTML tags

Here are the most important ones to start with.

Headings

<h1>Main heading</h1>
<h2>Sub heading</h2>
<h3>Smaller heading</h3>

Use headings for structure, not styling.


Paragraph

<p>This is a paragraph</p>

Used for normal text.


Div

<div>Some content</div>

A container.

Used to group elements.

Very common. Very powerful.


Span

<span>Some text</span>

Inline container.

Used for small pieces of text.


<ahref="<https://example.com>">Visit site</a>

Used for navigation.


Image

<imgsrc="image.jpg"alt="Description">

Displays an image.


Why you should inspect HTML in the browser

This is a pro tip.

Right click any website

Click Inspect

You will see real HTML used by professionals.

This helps you:

  • Understand structure

  • Learn naming patterns

  • See how elements are nested

This is how you level up fast.


Correct Mindset for learning HTML

  • HTML is structure, not style

  • Do not memorize everything

  • Practice small examples

  • View source of real websites

  • Master basics before moving forward

Once HTML is solid, CSS and JavaScript become much easier.