[html5] Understanding HGROUP
Brian Tremblay
webmaster at tsmchughs.com
Thu Jun 11 01:11:41 PDT 2015
On 6/11/15 12:02 AM, Matthew Jelenic wrote:
>
> <hgroup>
>
> <h1>The reality dysfunction</h1>
>
> <h2>Space is not the only void</h2>
>
> </hrgoup>
>
>
> 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
>
> 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
The <h2> is not stripped of its purpose. (It has uses other than as part
of a document outline.) Here, <h2> is a sub-heading.
> isn't that like wrapping an <image> in a special tag that will make it
> display only the alt text?
<hgroup> doesn't erase <h2>'s semantics, except as relates to the outline.
> 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./
>
>
> "Space is not the only void" does not start or imply it's own section
Only because it is in <hgroup>. Consider this markup:
<h1>pets in comics</h1>
<h2>dogs</h2> <!-- subsection of "pets" -->
<ul>
<li>Snoopy</li>
<li>Odie</li>
</ul>
<h2>cats</h2> <!-- subsection of "pets" -->
<ul>
<li>Garfield</li>
<li>Hobbes</li>
</ul>
Each <h2> element starts a subsection, and is part of the document
outline. Compare to this:
<hgroup>
<h1>pets in comics</h1>
<h2>furry funny friends</h2> <!-- *not* a subsection of "pets" -->
</hgroup>
<h2>dogs</h2> <!-- subsection of "pets" -->
<ul>
<li>Snoopy</li>
<li>Odie</li>
</ul>
<!-- etc. -->
> 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>? >
>
> <header>
>
> <h1>The reality dysfunction</h1>
>
> <p>Space is not the only void</p>
>
> </header>
>
>
> It's semantically clear that the two are parts of a larger header
> unit/title information.... Also, the outline is what we would expect.
IMHO, there's nothing wrong with that markup. (See below for my doubts
as to the usefulness of some of the new elements in html5.)
> it feels like the <h2> in the WHATWG comes from a desire to
> quickly style, not because it's the most appropriate tag.
It's not for style purposes. It is to replace the empty semantics of
<div class="heading"> and <div class="subhead">.
To be fair to your question, I'm not sure of the usefulness of several
new elements. I think there's a certain bit of "we see <div class="foo">
on lots of pages, let's create element <foo> to replace it". The most
pointless, to me, is <main>. I have no idea what it's supposed to do. My
page has main content. It's everything that's not <nav> and not <aside>.
Likewise, I'm not sure how <hgroup><h1><h2> offers anything better
practically speaking than <header><h1><p>.
--
Brian Tremblay
More information about the Help
mailing list