[html5] Understanding HGROUP

Matthew Jelenic matthew.jelenic at gmail.com
Thu Jun 11 00:02:43 PDT 2015


Hello WHATWG People,

I'm doing some development work for a personal site and I'm trying to get
my head around some best practices. My question today is about *<HGROUP>*.
I know that the W3C canned it and that it lives on in the WhatWG spec, I
also know that most browsers recognize the tag and it's usage. I know what
it's for (technically) but I don't understand *why* I would use it in place
of other tags - so as opposed to leaving this potentially useful tag alone,
I would like to get my head around it - with your help!

I think the easiest way to do this would be go over the examples shown in
the spec and how I'd mark them up instead, so let's do that! I'll also
cover my thoughts so you know where I am coming from, so that you can help
correct my thinking if that's where the problem lies. Please read the below
in the tones of curiosity and eagerness to learn that it is intended - as
we all know, tone is hard to convey in this format.

The examples I am referencing can be found at:
https://html.spec.whatwg.org/multipage/semantics.html#the-hgroup-element

*Provided Example 1:*
<!-- Release the code -->

<hgroup>

<h1>The reality dysfunction</h1>

<h2>Space is not the only void</h2>

</hrgoup>

<!-- Code's done -->

So, we use the above markup on a page and the result we want is this:

   1. The User Agent renders the headings as you would expect
   2. The outline document ignores all but the highest level heading, in
   this case, the H1

Okie dokie, I understand that. I can see what it does. But, I don't
understand *why* you would mark it up like that. If you use a tag and then
wrap it in another tag that will strip it of its primary purpose isn't that
like wrapping an <image> in a special tag that will make it display only
the alt text? If you don't want the baggage associated with a tag isn't
that a sign that your using the wrong tag? I suspect I am missing something.

When I think of marking up that "Space is not the only void", I don't think
heading. From the WHATWG Spec:

> *Subsequent headings of equal or higher rank start new (implied) sections,
> headings of lower rank start implied subsections that are part of the
> previous one. In both cases, the element represents the heading of the
> implied section.*
>
4.3.11 Headings and Sections <http://Subsequent headings of equal or higher
rank start new (implied) sections, headings of lower rank start implied
subsections that are part of the previous one. In both cases, the element
represents the heading of the implied section.>

"Space is not the only void" does not start or imply it's own section,
which is why <hgroup> would be stripping it of this meaning. The phrase may
be important as a component of the title, but it's not a heading of it's
own right. So, we have a piece of information that we want to keep with the
heading, as it is associated, but the item isn't important enough to appear
in the document outline. Isn't this a job for our friend Mr <Header>?

<!-- Release the code -->

<header>

<h1>The reality dysfunction</h1>

<p>Space is not the only void</p>

</header>

<!-- Code's done -->

It's semantically clear that the two are parts of a larger header
unit/title information and through some header specific CSS we can make
that <p> look however we want, be it almost as big as the h1 or otherwise.
Also, the outline is what we would expect. I know it's up to the developer
to mark things up how they see fit, but it feels like the <h2> in the
WHATWG comes from a desire to quickly style, not because it's the most
appropriate tag.

I had started to go through the other examples, but my response was the
same, so I'll spare you the repetition. :)

At the end of the day, I know I don't have to use <HGROUP> if I don't want
to, but I hate leaving a tool in the box just because I didn't take the
time to learn how to use it. It's in the spec so there are enough people
who found a use for it. With what I've said above regarding my thoughts on
marking up the provided examples, can anyone tell me when/where/why
<HGROUP> would be the correct tag to use, please?

Thank you kindly for your time!

Cheers,
MattyJ

---
Matthew Jelenic
Matthew.jelenic at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/help-whatwg.org/attachments/20150611/cad844c8/attachment.htm>


More information about the Help mailing list