- To create a sub-paragraph within a paragraph:
<p>This is the main paragraph.
<p>This is a sub-paragraph, nested within the main paragraph.</p>
</p>
It's worth noting that nested <p> tags may cause an unexpected behavior on many web browsers and the above example would not be considered as a valid HTML.
- To create a sub-heading within a paragraph:
<p>This is the main paragraph. <strong>
<p>This is a sub-heading, nested within the main paragraph.</p>
</strong></p>
This also would not be considered as a valid HTML.
- To create a text that has multiple levels of headings:
<div>
<h1>This is the main heading</h1>
<p>This is the main paragraph. <strong>
<h2>This is a sub-heading, nested within the main paragraph</h2>
<p>This is a sub-paragraph, nested within the main paragraph.</p>
</strong></p>
</div>
This is a valid example, it is common to see nested tags of different types, e.g. <h1> or <h2> inside of a <p> tag or <p> tag inside <div> and so on.
It's worth noting that it is common to see nested tags of different types, as it's usually done to give more semantic meaning, layout and structure to the webpage.
No comments:
Post a Comment