[html5] Template questions...

Jukka K. Korpela jukka.k.korpela at kolumbus.fi
Mon May 16 19:38:41 PDT 2011


17.5.2011 0:08, Micky Hulse wrote:

>> So it would be safer to write, say,
>> <hgroup>
>>   <h1>Article title<br>
>>   <small>Subhead</small>
>>   </h1>
>>   <time>...</time>
>> </hgroup>
>
> Ooooh, I like that! Seems like a good spot to use<small>.
>
> I am also happy to see that you included<time>  in the<hgroup>. I was
> under the assumption that<hgroup>  could only contain H* tags. I am
> glad to see that other tags can be put in there too.

Oops, sorry; they can't.
I confused <hgroup> (which is _heading_ group and therefore accepts only 
<h*> elements as children) with <header> (which is generic _header_ and 
accepts "flow" content, i.e. pretty much anything).

So you could use <header> markup here. Inside it, you could use <hgroup> 
that contains just the <h1> or, if you move the Subhead out of it into a 
<h2>, both <h1> and <h2>. But to include <time> inside <hgroup>, you 
would indeed need to wrap it inside <h3> for example.

> Just out of curiosity, what are you thoughts about using<hgroup>  when
> there is only one<H*>  tag?

Well, the definition says that <hgroup> contains one or more h1, h2, h3, 
h4, h5, and/or h6. But as such, "one or more" just means that it must 
not be empty, as it is common in syntactic definitions to use "one or 
more" for that. It implies that a single h1, h2, h3, h4, h5, or h6 is 
_allowed_. But it's not necessarily useful, and it's actually difficult 
to see why you would want to wrap a single heading into a heading group. 
The prose at 4.4.7 says that hgroup "is used to group a set of h1–h6 
elements when the heading has multiple levels, such as subheadings, 
alternative titles, or taglines."

But if you have sections with <hgroup> elements and some sections with 
just simple headings, you could wrap even then simple headings inside 
<hgroup>. You might do this for uniformity, or for the more practical 
reason of creating some style for <hgroup> (say, a particular 
background, or a border around) and have it applied to the lone headings 
as well. Or if you do some scripting that processes headings of 
sections, you could then make it simpler by just picking up a section's 
<hgroup>.

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/



More information about the Help mailing list