Can you describe why hgroup was dropped and how the markup can be addressed today with an example?

Answer Posted / chaitu

The hgroup element was introduced to group multiple heading elements (h1-h6) in order to avoid the creation of an unintended sublevel in the hierarchy. To understand what problem it tried to address, let’s consider the following markup:

<article>

<h1>Main title</h1>

<h2>This is a subtitle</h2>

<p>This is the content of this section</p>

</article>

Outlining the document hierarchy of the previous snippet gives us the following representation:

h1
|
---h2
|
p

This simple schema shows that the paragraph content of the snippet is seen as the content of the h2 instead of the h1, regardless if this was the intended behavior or not. So if the intention was simply to create a subheading and to associate the p with h1, the original markup was incorrect.

The hgroup element was introduced to address this issue with ease. Therefore, it was removed from the HTML5 specification in April 2013, due to lack of implementations and lack of use cases, making its use invalid.

A possible solution to create a subtitle so that the paragraph is associated to the h1 is shown below:

<article>

<h1>

Main title

<span>This is a subtitle</span>

</h1>

<p>This is the content of this section</p>

</article>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

No New Questions to Answer in this Category !!    You can

Post New Questions

Answer Questions in Different Category