0% completed
In this lesson, you'll learn about HTML tags, the fundamental building blocks of any HTML document. Understanding how to use tags correctly is essential for creating well-structured and functional web pages.
HTML tags are the keywords enclosed within angle brackets (< >
) that define the structure and content of an HTML document. They tell the browser how to display the content on the web page.
Most HTML tags come in pairs: an opening tag and a closing tag. Some tags are self-closing and do not require a closing tag.
Opening Tag: Marks the beginning of an element.
<tagname>
Closing Tag: Marks the end of an element. It includes a forward slash (/
) before the tag name.
</tagname>
Self-Closing Tag: Some tags do not require a closing tag and are self-contained.
<tagname />
Let's explore different types of HTML tags with examples.
The <h1>
tag defines the most important heading on your page. There are six levels of headings in HTML, from <h1>
to <h6>
, with <h1>
being the highest level.
Syntax:
<h1>Your Heading Here</h1>
Explanation:
<h1>
: Opening tag for the heading.Your Heading Here
: The text that will appear as the heading.</h1>
: Closing tag for the heading.Example 1: Main Title
<h1>Welcome to TechGrind.io</h1>
Example 2: Section Title
<h1>Our Services</h1>
The <br>
tag inserts a single line break. It is a self-closing tag and does not require a closing tag.
Syntax:
<br />
Explanation:
<br />
: Inserts a line break, moving the following content to the next line.Example 1: Breaking Lines in an Address
<h1>Our Office</h1> <p>123 Design Street<br /> Cityville, Country</p>
Example 2: Formatting a Poem
<h1>Happy Birthday!</h1> <p> Wishing you a day filled with joy,<br /> Laughter, and all your favorite things.<br /> Enjoy your special day! </p>
Let's combine the <h1>
, <a>
, and <br>
tags in a single HTML document to see how they work together.
Explanation of the Final Example:
<h1>
tag to display the main title "Welcome to TechGrind.io".<br />
tag adds space below the heading......
.....
.....