Skip to main content

Command Palette

Search for a command to run...

Understanding HTML Tags and Elements

Published
β€’2 min read

Whenever we open a website, we see text, images, buttons, and links.

But how does a browser know what is a heading, what is a paragraph, or what is a button?

The answer is HTML.

To build even the simplest webpage, we must understand:

HTML tags

HTML elements

How content is structured

Let’s break this down in the simplest way possible.

What Is HTML and Why Do We Use It? 🌐

HTML (HyperText Markup Language) is the structure language of the web.

HTML tells the browser:

What content exists

What type of content it is

How content is organized

πŸ“Œ HTML does not add styles or logic.

It only defines structure.

πŸ§’ Simple analogy:

HTML is the skeleton of a webpage.

What Is an HTML Tag? 🏷️

An HTML tag is a keyword wrapped in angle brackets.

Example:

<p>

Tags tell the browser:

β€œThis content has a specific meaning.”

Examples of tags:

<p> β†’ paragraph

<h1> β†’ heading

<img> β†’ image

Opening Tag, Closing Tag, and Content πŸ”“πŸ”’

Most HTML tags come in pairs.

<p>Hello World</p>

Breakdown:

<p> β†’ Opening tag

Hello World β†’ Content

</p> β†’ Closing tag

πŸ“Œ The closing tag has a / to show the end.

πŸ§’ Think of it like:

Start talking β†’ talk β†’ stop talking

What Is an HTML Element? 🧩

An HTML element is the complete unit.

It includes:

Opening tag

Content

Closing tag

Example:

<h1>Welcome</h1>

πŸ“Œ This entire line is one HTML element.

πŸ‘‰ Tag β‰  Element

πŸ‘‰ Element = Tag + Content

Self-Closing (Void) Elements βœ‚οΈ

Some elements don’t have content, so they don’t need closing tags.

These are called self-closing or void elements.

Examples:

<img src="image.jpg">

<br>

<hr>

<input>

πŸ“Œ These elements exist to do something, not to wrap text.

πŸ§’ Analogy:

Like a switch β€” just click, no sentence inside

Block-Level vs Inline Elements πŸ“

Block-Level Elements 🧱

Take full width

Start on a new line

Examples:

<div>

<p>

<h1>

<section>

πŸ§’ Like a full row in a notebook.

Inline Elements 🧩

Take only required space

Stay in the same line

Examples:

<span>

<a>

<strong>

<img>

πŸ§’ Like words in a sentence.

Commonly Used HTML Tags ⭐

Text Content

<h1> to <h6> β†’ Headings

<p> β†’ Paragraph

<span> β†’ Inline text

<strong> β†’ Bold text

<em> β†’ Italic text

Links & Media

<a> β†’ Link

<img> β†’ Image

<video> β†’ Video

<audio> β†’ Audio

Layout & Structure

<div> β†’ Container

<section> β†’ Section

<header> β†’ Header

<footer> β†’ Footer

Forms

<form> β†’ Form

<input> β†’ Input field

<button> β†’ Button

<label> β†’ Label

HTML is simple, but powerful.

Tags define meaning

Elements define structure

Block and inline elements define layout