Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
4 min read

1. What is HTML and Why Do We Use It?

HTML stands for HyperText Markup Language. It is the basic building block of every website on the internet.

If we compare a website to a human body:

  • HTML = Skeleton (structure)

  • CSS = Skin and clothes (design)

  • JavaScript = Brain (logic and behavior)

HTML’s main job is to structure content:

  • Headings

  • Paragraphs

  • Images

  • Links

  • Forms

  • Tables

Without HTML, a webpage would have no structure at all.


2. What is an HTML Tag?

An HTML tag is a keyword written inside angle brackets < > that tells the browser what type of content it is.

Example:

<p>This is a paragraph</p>

Here:

  • <p> → opening tag

  • </p> → closing tag

The browser understands:

“This content should be treated as a paragraph.”


3. Opening Tag, Closing Tag, and Content

Most HTML tags come in pairs:

<tagname> content </tagname>

Example:

<h1>Welcome to My Website</h1>

Breakdown:

  • <h1> → Opening tag

  • Welcome to My Website → Content

  • </h1> → Closing tag

Together they form a complete structure.


4. What is an HTML Element?

This is one of the most important concepts.

Tag vs Element (Very Important)

TermMeaning
TagOnly the markup (<p>)
ElementTag + content + closing tag

Example:

<p>Hello World</p>
  • <p> → Tag

  • <p>Hello World</p> → Element

Simple Analogy

Think of it like a box:

  • The tag is the box boundary

  • The element is the box + what’s inside


5. Self-Closing (Void) Elements

Some elements do not need a closing tag because they don’t wrap content.

These are called void elements.

Examples:

<img src="photo.jpg">
<br>
<hr>
<input>

They:

  • Don’t have content inside

  • Just perform a single task

Example:

<p>Hello<br>World</p>

<br> simply breaks the line.


6. Block-Level vs Inline Elements

This defines how elements behave on the page.

Block-Level Elements

They:

  • Take full width

  • Start on a new line

Examples:

<h1>, <p>, <div>, <section>, <article>

Example:

<p>First paragraph</p>
<p>Second paragraph</p>

They appear on separate lines.


Inline Elements

They:

  • Take only required space

  • Stay in the same line

Examples:

<span>, <a>, <strong>, <em>

Example:

<p>This is <strong>important</strong> text.</p>

<strong> does not break the line.


7. Commonly Used HTML Tags (Beginner List)

Text Content

<h1> to <h6>  → Headings  
<p>           → Paragraph  
<span>       → Inline text container  
<strong>     → Bold  
<em>         → Italic

Layout & Structure

<div>        → Block container  
<section>    → Section
<a>          → Link  
<img>        → Image

Lists

<ul> → Unordered list  
<ol> → Ordered list  
<li> → List item

Line & Separation

<br> → Line break  
<hr> → Horizontal line

8. HTML Tag vs Element (Diagram Concept)

<p>Hello</p>

<p>  → Opening tag  
Hello → Content  
</p> → Closing tag  

Whole thing = HTML Element

9. Block vs Inline Layout (Visual Idea)

Block

[  DIV  ]
[  DIV  ]
[  DIV  ]

Inline

[SPAN][SPAN][SPAN]

10. Why Understanding This Matters

If you don’t understand:

  • Tags

  • Elements

  • Block vs inline

Then:

  • CSS will confuse you

  • Layout will feel random

  • Debugging will be painful

HTML mastery = strong foundation for web development.


11. Inspecting HTML in the Browser (Must Do!)

Every learner should do this:

  1. Open any website

  2. Right click → Inspect

  3. Go to Elements tab

You will see real HTML like:

<div class="header">
  <h1>Amazon</h1>
</div>

This is how you learn from real websites.


12. Final Mental Model

Think of HTML as:

A document made of boxes inside boxes.

Each box is:

  • An element

  • With a tag

  • Containing content

  • And having a role


Conclusion

HTML tags and elements are the alphabet of the web.

Once you understand:

  • What a tag is

  • What an element is

  • How block and inline work

You can:

  • Read any HTML code

  • Write clean layouts

  • Learn CSS & JS easily

HTML is simple — but it decides how everything else works.
Master this, and web development becomes 10x easier.