HTML 5

Chapter 3: Understanding HTML Tags

πŸ“˜ Chapter 3: Understanding HTML Tags

πŸ”– What Are HTML Tags?

In HTML, the core building blocks are called tags. Tags tell the browser how to display and structure content on a web page.

HTML tags are enclosed within angle brackets:

<tagname> Content </tagname>

πŸ‘‰ Example:

<title>My Web Page</title>
  • <title> is the opening tag
  • </title> is the closing tag
  • My Web Page is the content

🧩 Types of HTML Tags

There are mainly two types of HTML tags:


πŸ…°οΈ 1. Paired Tags (Container Tags)

These tags come in pairs β€” an opening tag and a closing tag.

  • The opening tag starts with <tagname>
  • The closing tag starts with </tagname>

πŸ“Œ Examples:

<html>
  <!-- Web content goes here -->
</html>

<body>
  <!-- Body content goes here -->
</body>

In the above examples:

  • <html> and </html> form a pair
  • <body> and </body> form another pair

These are called Paired Tags because they “contain” content between them.


πŸ…±οΈ 2. Non-Paired Tags (Empty Tags)

These tags do not have a closing tag. They are self-contained and are used to insert elements like line breaks, images, etc.

πŸ“Œ Examples:

<br>   <!-- Line break -->
<img src="logo.png" alt="Logo">  <!-- Image -->
<hr>   <!-- Horizontal line -->

These are known as Non-Paired or Empty Tags because they do not wrap any content and do not need a closing tag.

πŸ‘‰ In HTML5, it’s optional to use the trailing slash (/), so <br> and <br /> both work.


πŸ“Œ Summary

Tag Type Description Example
Paired Tags Have both opening and closing tags <body> ... </body>
Non-Paired Tags Have only an opening tag <br>, <img>, <hr>

Leave a Reply

Your email address will not be published. Required fields are marked *