Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
•4 min read•View as Markdown
Understanding HTML Tags and Elements
J

I'm Janmejai Singh, a Full Stack Developer specializing in the MERN stack, on a mission to blend technical excellence with creative flair. From machine learning and blockchain breakthroughs to game development, 3D design, and animation adventures, I bring humor and heart to every line of code. Join me as I turn innovative ideas into digital masterpieces!

Every website you see from Google to Instagram is built on one simple foundation: HTML.

Before styling with CSS or adding interactivity with JavaScript, you must understand HTML tags and elements. They are the building blocks of the web.


What Is HTML and Why Do We Use It?

HTML stands for HyperText Markup Language.

HTML is used to:

  • Structure web content

  • Define headings, paragraphs, images, links, and sections

  • Tell the browser what each piece of content is

Think of HTML as:

🦴 The skeleton of a webpage — it gives shape and structure.

Without HTML:

  • Browsers wouldn’t know what text is a heading

  • Images wouldn’t appear correctly

  • Web pages would have no structure


What Is an HTML Tag?

An HTML tag is a keyword wrapped in angle brackets (< >) that tells the browser how to treat content.

Example

<p>

Here:

  • <p> is a tag

  • It tells the browser this content is a paragraph

Real‑World Analogy (Sentence / Box)

Think of a tag like a label on a box:

  • The label says what type of content is inside

  • The box holds the content


Opening Tag, Closing Tag, and Content

Most HTML tags come in pairs.

Example

<p>Hello World</p>

Breakdown:

  • <p> → Opening tag

  • Hello World → Content

  • </p> → Closing tag

The closing tag has a forward slash (/).


What Is an HTML Element?

This is where beginners often get confused.

An HTML element includes the opening tag, content, and closing tag together.

Example

<p>Hello World</p>

Here:

  • <p> → tag

  • </p> → tag

  • Entire line → HTML element

Simple Rule

  • Tag → part of HTML syntax

  • Element → complete structure


HTML Tag vs HTML Element (Clear Difference)

TermMeaning
HTML TagInstruction to browser (<p>)
HTML ElementTag + content + closing tag

You write tags. Together, they form elements.


Self‑Closing (Void) Elements

Some HTML elements don’t wrap content.

These are called self‑closing or void elements.

Common Examples

<img src="image.jpg" alt="sample">
<br>
<hr>
<input type="text">

Key Points

  • No closing tag

  • Used for media, breaks, inputs


Block‑Level vs Inline Elements

HTML elements are broadly divided into block-level and inline elements.


Block‑Level Elements

Block elements:

  • Start on a new line

  • Take the full available width

Examples

<h1>Heading</h1>
<p>Paragraph</p>
<div>Section</div>

Common block elements:

  • div

  • p

  • h1 to h6

  • section


Inline Elements

Inline elements:

  • Stay within the same line

  • Take only the required width

Examples

<span>Text</span>
<a href="#">Link</a>
<strong>Bold</strong>

Common inline elements:

  • span

  • a

  • strong

  • em


Block vs Inline: Visual Idea

Block elements stack vertically ↓
Inline elements flow horizontally →


Commonly Used HTML Tags (Beginner‑Friendly)

TagPurpose
h1Main heading
pParagraph
divContainer
spanInline container
aLink
imgImage
ul, liLists

These tags cover 80% of beginner HTML needs.


Right‑click on any webpage → Inspect.

You’ll see:

  • HTML structure

  • Tags and elements

  • How browsers read your code

Great developers inspect HTML daily.


HTML Tag vs Element Breakdown (Diagram Idea)

<p> + Hello + </p> → HTML Element


Final Takeaway

  • HTML gives structure

  • Tags are instructions

  • Elements are complete building blocks

  • Block and inline elements behave differently

If you understand tags and elements clearly:

  • CSS becomes easier

  • Layouts make sense

  • Debugging improves

Strong HTML fundamentals make you a better web developer.