You are currently viewing Nested Tags in HTML
Nested HTML tags

Nested Tags in HTML

In this post we will learn what do we mean with Nested HTML tags and how to create them.

This Video Could Help You Deep Understand:

Nested Tag Video

Normal HTML Example

HTML elements can be nested (elements can contain elements). In addition, all HTML documents consist of nested HTML elements. This example contains four HTML elements:

 <!DOCTYPE html>
<html>
<body>
<h1>Header 1</h1>
<p>Sample paragraph.</p>
</body>
</html> 

Nested Tag Example:

<!DOCTYPE html>
<html>
<body>

<p> This is the <h2>Nested Tag Example  from <br>
 <a href="www.safhatech.com" >safhatech.com</a> website </h2></p>
</body>
</html> 

In the previous example we have created nested tag example which is like the following:

First of all, we created HTML normal code html , body and closing tags. But the most important part in our example is the content inside the paragraph <p>:


<p> This is the <h2>Nested Tag Example  from <br/>
 <a href="www.safhatech.com" >safhatech.com</a> website </h2></p>

That code which is in <p> means we have text inside the paragraph <p> which is ” This is the”.

Then we added the header 2 tag <h2> inside the paragraph with text ” Nested Tag Example from “

Next we have added the break line tag <br/> that print new line.

After that, we added link tag <a> which create our link to “safhatech.com” inside <h2> and inside <p>.

Finally, we closed each tag we have created like the following text “</a> website </h2></p>”.

So that what we mean with nested tags.


This post is one of the HTML5 for deep understanding course. where we will learn every common elements from basic to the advanced element.

In addition each lesson has a video which you could visit and watch for more practicing and for deep understanding.

We hope that we could give the best for you and for the deep and easy understanding.

You could follow the series from our website SAFHATECH.com and go to categories and then programming and then Choose the course you want then just click next post to go step by step.

Finally we hope every thing is works as you suspect.


Consequently You could follow us at :

Website URL: https://www.safhatech.com/

Youtube: https://www.youtube.com/channel/UCIVzh6iykNowNcOUT5Gfasw

Twitter: http:// https://twitter.com/safhatech

Instegram: https://www.instagram.com/safhatech

Facebook: http:// https://www.facebook.com/Safhatech-487171875443687

Phone:967772223681

Leave a Reply