📝 Learn About HTML Tags in Detail: Complete Guide with Examples for Beginners
📌 HTML Tags Explained with Examples | Beginner’s Guide to HTML | Learn About HTML Tags in Detail
🧩 What Are HTML Tags?
HTML tags are the building blocks of web pages. They are used to structure content and tell the browser how to display it.
📌 Syntax of a Tag:
✅ Most HTML tags come in pairs:
-
Opening tag:
<p>
-
Closing tag:
</p>
Example:
🧱 Categories of HTML Tags
HTML tags can be divided into several categories based on their purpose. Let’s explore them one by one:
1️⃣ Text Formatting Tags
Used to format or emphasize text on a webpage.
Tag | Purpose | Example |
---|---|---|
<h1> to <h6> |
Headings (from biggest to smallest) | <h1>Title</h1> |
<p> |
Paragraph | <p>This is a paragraph.</p> |
<br> |
Line break | Line 1<br>Line 2 |
<hr> |
Horizontal line | <hr> |
<strong> |
Bold text | <strong>Important!</strong> |
<em> |
Italic text | <em>Emphasized</em> |
<u> |
Underline text | <u>Underlined</u> |
2️⃣ Hyperlink Tag
Used to create clickable links.
Attribute | Purpose |
---|---|
href |
URL of the page to link to |
target="_blank" |
Opens link in a new tab |
3️⃣ Image Tag
Used to display images.
Attribute | Purpose |
---|---|
src |
File path of the image |
alt |
Alternative text (for screen readers or if image fails to load) |
width , height |
To resize the image (optional) |
4️⃣ List Tags
✅ Unordered List:
✅ Ordered List:
Tag | Purpose |
---|---|
<ul> |
Unordered (bulleted) list |
<ol> |
Ordered (numbered) list |
<li> |
List item |
5️⃣ Table Tags
Tables help organize data in rows and columns.
Tag | Purpose |
---|---|
<table> |
Defines a table |
<tr> |
Table row |
<th> |
Table header |
<td> |
Table data/cell |
6️⃣ Form Tags
Used to take input from users.
Tag | Purpose |
---|---|
<form> |
Creates the form |
<input> |
Takes user input |
<label> |
Label for the input |
<textarea> |
Multiline input |
<button> |
Button inside the form |
7️⃣ Media Tags
Tag | Purpose | Example |
---|---|---|
<img> |
Display image | <img src="pic.jpg"> |
<audio> |
Embed audio | <audio controls><source src="song.mp3"></audio> |
<video> |
Embed video | <video controls><source src="movie.mp4"></video> |
8️⃣ Container Tags (Div & Span)
Used to group or style HTML content.
Tag | Purpose |
---|---|
<div> |
Block-level container |
<span> |
Inline container |
🛑 Self-Closing Tags in HTML
Some HTML tags don’t need a closing tag. These are called self-closing or void elements.
Examples:
📌 Best Practices for Using Tags
-
✅ Use semantic tags like
<header>
,<footer>
,<article>
for cleaner HTML5 code. -
✅ Always close your tags properly.
-
✅ Keep code indented and readable.
-
✅ Use
alt
attributes for images. -
✅ Nest elements properly (never put a
<div>
inside<p>
).
✅ Summary Table: Most Used HTML Tags
Tag | Use |
---|---|
<html> , <head> , <body> |
Page structure |
<h1> to <h6> |
Headings |
<p> |
Paragraph |
<a> |
Hyperlink |
<img> |
Image |
<ul> , <ol> , <li> |
Lists |
<table> , <tr> , <td> |
Tables |
<form> , <input> |
Forms |
<div> , <span> |
Containers |
🧭 Missed Step 1?
👉 Learn HTML for Beginners: Step-by-Step Guide to Start Web Development
🎯 What’s Next?
In the next blog post, we’ll cover:
🌐 “Creating a Simple Webpage: Putting HTML Tags into Practice”
You’ll learn how to combine all these tags to create your first complete webpage.
Learn HTML