Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
•4 min read•View as Markdown

Introduction: HTML as the Skeleton of a Webpage

When you open any website, what you see — text, images, buttons, headings — is built using HTML (HyperText Markup Language). HTML is the standard language used to create and structure webpages. If a website were a human body, HTML would be the skeleton. It provides structure, while CSS adds styling and JavaScript adds behavior.

HTML tells the browser what each piece of content is — whether it’s a heading, a paragraph, an image, or a link. Without HTML, a webpage would not have any organized structure.


What is an HTML Tag?

An HTML tag is a keyword enclosed inside angle brackets < >. Tags tell the browser how to display content. For example

<p>Hello World</p>

Here, <p> is a tag that defines a paragraph.

You can think of a tag like a label on a box. The label tells you what is inside. Similarly, HTML tags tell the browser what type of content is inside.


Opening Tag, Closing Tag, and Content

Most HTML tags come in pairs:

<h1>Welcome to My Website</h1>
  • <h1> → Opening tag

  • </h1> → Closing tag

  • Welcome to My Website → Content

The closing tag has a forward slash / before the tag name. The content placed between opening and closing tags is what appears on the webpage.

Think of it like a sandwich:

  • Opening tag → Top bread

  • Content → Filling

  • Closing tag → Bottom bread

Together, they create a complete structure.


What is an HTML Element?

An HTML element includes:

Opening tag + Content + Closing tag

So in this example:

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

The entire line is called an HTML element.

In simple terms:

  • A tag is just the label (<p>)

  • An element is the complete structure including content

Understanding this difference is very important for beginners.


Self-Closing (Void) Elements

Some HTML elements do not have closing tags because they do not wrap content. These are called self-closing or void elements.

Examples:

<img src="image.jpg">
<br>
<hr>
  • <img> displays an image

  • <br> creates a line break

  • <hr> creates a horizontal line

These elements do not need a closing tag because they do not contain content inside them.


Block-Level vs Inline Elements

HTML elements are divided into two main types: block-level elements and inline elements.

Block-Level Elements

Block elements:

  • Start on a new line

  • Take full width available

Examples:

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

These elements create structure and layout sections.


Inline Elements

Inline elements:

  • Do not start on a new line

  • Take only as much width as needed

Examples:

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

Inline elements are usually used inside block elements to style small parts of content.

For example:

<p>This is a <span>highlighted</span> word.</p>

Here, <span> modifies only part of the sentence.


Commonly Used HTML Tags

Here are some basic and important tags beginners should know:

  • <h1> to <h6> → Headings

  • <p> → Paragraph

  • <div> → Container for grouping elements

  • <span> → Inline container

  • <a> → Link

  • <img> → Image

  • <ul> and <ol> → Lists

  • <li> → List item

These tags form the foundation of every webpage.


Inspecting HTML in the Browser

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

Right-click on any webpage and click Inspect (or press F12). You will see the HTML structure of that page. This helps you understand how professional websites are built.

Practice observing:

  • How headings are used

  • How paragraphs are structured

  • How divs group content

Learning by inspection improves understanding quickly.


Conclusion

HTML is the foundation of web development. It gives structure and meaning to content on a webpage. Tags act as labels, while elements represent the complete structure including content. Understanding the difference between tags and elements, learning about self-closing tags, and recognizing block vs inline elements are essential first steps in becoming a web developer.

Mastering these basics builds a strong foundation for learning CSS and JavaScript later. Start simple, experiment with small examples, and inspect webpages regularly — that’s the best way to grow in web development.