Nesting of tag in HTML is widely used while playing with the HTML code. This is the most important while doing HTML coding.
HTML tag should arrange properly and closed properly. If the HTML tags are not arranged or closed properly then there may occur problems.
What is the Nesting of HTML Tag? Simply the nesting of the tag is using HTML tag inside tag is known as the nesting of tags.
Similarly: As we know in programming loop inside loop is known as nesting of loop.
<p><center><b>Cricket and</b><i>football are awesome games</i></center></p>
Cricket and football are awesome games
See the above example of the nesting of the html tags.
- <p> tag started.
- <center> tag started.
- <b> tag started and immediately it is closed </b> because it’s work is finish.
- <i> tag started and it is also closed before </center> tag because the <i> tag is started after <center> tag.
- </center> tag closed because it is started after <p> tag.
- Now finally </p> tag closed.
Note: You must have to close your tags sequentially one after another. .
- <html> is the document so it started first and closed last </html>
- <head> is the decoration section, it contains title, meta tag for website so it started after <html> tag and close before<body> tag. or closed after defining the decorations sections, titles and meta tag.
- <title> comes inside the <head> tag and it starts and immediately it closed </title>.
- <body> it contains content of the websites so it comes after <html> and <head> tags and ends before </html> tag.