[whatwg] <hgroup> functionality absorbed into <header>?

Ian Hickson ian at hixie.ch
Sun Oct 18 14:09:13 PDT 2009


On Sun, 18 Oct 2009, Kornel Lesinski wrote:
> On Sun, 18 Oct 2009 08:54:59 +0100, Ian Hickson <ian at hixie.ch> wrote:
> > > 
> > > Your version with split <h2> seems to use it only for visual effect.
> > 
> > Not just visual, but presentational, yes, pretty much. It also makes 
> > it clear how to generate the outline.
> 
> I don't understand how presentational <h2>s make outline clear. I
> thought they're an exception that didn't work simple outline algorithm:
> 
> http://validator.w3.org/check?uri=http%3A%2F%2Fwww.w3.org%2FTR%2Fhtml5%2F&outline=1#outlineresult
> 
> and <hgroup> exists to resolve ambiguity caused by presentational use of 
> headers.

I mean that it defines exactly what value to use in the outline.

This:

   <h1>The Reality Dysfunction; Space is not the only void</h1>

...would result in an outline that had the following title:

   "The Reality Dysfunction; Space is not the only void"

However, this:

   <hgroup>
    <h1>The Reality Dysfunction</h1>
    <h2>Space is not the only void</h2>
   </hgroup>

...results in an outline with just:

   "The Reality Dysfunction"

...as desired. (A user agent could also include the subtitle, but it isn't 
required.)


> > > I still think that <subtitle> (subheader, tagline) would be just as 
> > > effective, less confusing and less likely to break outline when used 
> > > improperly...
> > 
> > How is <h2> confusing?
> 
> <h2> alone isn't. <hgroup> is the source of confusion.
> 
> * Difference between <hgroup> and <header> is not obvious. It wasn't to me
> when I first saw them, and this isn't first thread about them.

Sure, but people get it pretty quickly. Most of the threads are along the 
lines of "I don't like it", not "It does X" where X is wrong.


> * Makes meaning of <hx> overloaded (sometimes it's a header that affects 
> outline and level or other headers, sometimes it's a subheader that 
> doesn't do anything that header would).
> 
> Have you seen this post? 
> http://www.onderhond.com/blog/work/the-hgroup-tag I think it sums up 
> problems quite well.

If those are the problems, then I think we're doing pretty well. There 
were a couple of misunderstandings quickly addressed by the comments. As 
far as I can tell, the other concerns were all theoretical, such as not 
approving of the element taking its meaning from its parents. However, 
this is a pattern used all over HTML5, and I don't see why it's a problem.


> > I think something like <subtitle> is just as likely to be misused as 
> > <hgroup>, to be honest.
> 
> Sure, but it's much more fail-safe. If you use <header> instead of 
> <hgroup> or fail to use <hgroup>, you may significantly change structure 
> of the document.

That's clearly not the end of the world, since people are doing it all the 
time today!


> You can't make much damage with <subheader>. Sections will remain 
> correct and at worst you'll add wrong subtitles to headers.

There's plenty of damage you could make. What if someone decides that 
<header> should be <subheader> because it's in a section, and they end up 
putting entire sections in there, for instance? Authors have an unlimited 
capacity for misusing HTML.


> > Also, it has a much poorer legacy (backwards compatibility) story.
> 
> Both solutions have problems. I don't think ones are much worse than the 
> others.

I think <subheader> has far bigger problems than <hgroup> (primarily its 
lack of default styles in legacy UAs).


> <hgroup> breaks the outline

I still think this is incorrect. It fixes the outline in new UAs, and has 
no effect on legacy UAs.


> <subheader> is ignored. Without CSS <h2>s will be too large and have too 
> big margins.

The CSS is already there, though, since people are already using <h2> for 
this.


> With CSS <subheader> will work fine and doesn't limit styling 
> possibilities. <hgroup>'s content model doesn't allow any non-header 
> elements, so one can't add any extra hooks for styling:
> 
> <hgroup>
>   <h1/>
>   <div><!-- add fancy border around subheaders? -->
>     <h2/>
>     <h2/>
>   </div>
> </hgroup>

That's a good point. However, in general, I would encourage people to not 
insert HTML <div>s purely for styling; instead, in the future, XBL and CSS 
will hopefully provide the tools to address this. (We can always allow 
<div> later if this becomes a real problem.)


> Another thing - can you write XPath query that extracts all headers from 
> the document? Without <hgroup> it's simple. With <hgroup> I'm not sure 
> if I could manage to write correct query.

This problem exists in general in HTML -- can you write an XPath that 
selects the elements on a per-section basis, say? Or that selects all the 
third-level headers, including the right <h1>s in <section>s?

For that kind of thing we'll need pesudo-elements (in Selectors) or custom 
functions (in XPath).

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



More information about the whatwg mailing list