Re: hgroup: a possible alternative

On Mon, 10 Jan 2011, Toby Inkster wrote:

> Not sure if there's an open issue on hgroup that's accepting change
> proposals, but here's the stub of an alternative idea for discussion
> anyway.
>
> It seems to me that much of the dislike of <hgroup> can be solved by
> turning it inside out. Instead of:
>
> 	<hgroup>
> 		<h1>Medieval Beekeeping</h1>
> 		<h2>The evolution of an artform</h2>
> 	</hgroup>
>
> You could have:
>
> 	<h1>
> 		<hline>Medieval Beekeeping</hline>
> 		<hline small>The evolution of an artform</hline>
> 	</h1>

Why not <h1>Main Heading <subhead>Subheading</subhead></h1>, where a 
heading element can have 0 or more <subhead> children that represent 
subheadings (we can bikeshed over the name of course). This requires less 
markup than <hgroup> or this <hline> proposal. I also think it works 
marginally better for CSS since the selectors for each part are simpler 
(assuming we get :heading(n) to select n-th level headings):

:heading(n) {/*rules for the heading*/}
:heading(n) > subhead {/*special rules for the subheading*/}

Compared to <hgroup> it is more obvious what :heading would select (there 
is no <hgroup> vs child-that-represents-the-heading confusion) and it is 
easier to select the subheading(s) since they always have the same element 
name. Compared to <hline>+<hline small> it removes the need for an 
attribute selector.

Semantically, it is arguably less flexible than <hgroup> since one cannot 
have different subheadings of different rank, but that seems like a minor 
use-case. It has slightly different fallback behaviour since legacy UAs 
will presumably consider the whole element a single heading rather than 
multiple headings. This seems theoretically cleaner, although I don't know 
how much difference it makes in actual UAs. <subhead> also has the benefit 
of simplifying the outline algorithm somewhat compared to <hgroup>.

Received on Monday, 10 January 2011 22:50:30 UTC