[whatwg] The legend element

I found this post by Ian Hickson from August 15, 2006 in the list archive:

 > On Sat, 1 Apr 2006, Henri Sivonen wrote:
 > >
 > > Since the omission of <legend> does not cause any horrible effects,
 > > I suggest making <legend> optional and reaffirming that if it
 > > appears, it can appear only once per <fieldset> and only as the
 > > first child (ignoring whitespace).
 >
 > I agree, and I will do this as part of HTML5, where I am defining
 > content models. If you don't object, I'll leave this change out of WF2
 > for now. (If you do object, then let me know, and I'll shoehorn it in 
 > somehow.)

It looks like this change has not made it into the HTML5 spec so far.

Additionnally I want to suggest to make it possible to place the legend 
element outside the fieldset element, providing a "for" attribute (just 
as it is possible to place the label element apart from it's form field 
element).

Background: When writing template based applications, it can be useful 
to provide a placeholder for the whole fieldset, and another one for the 
legend, as template authors might want to place or style them individually.

Example - a questionnaire:

Template Variable {question} outputs:
<legend for="question1">What ist your favorite Pet?</legend>

Template Variable {answers} outputs:
<fieldset id="question1">
   <p><label><input type="radio" name="q1" value="Cat">Cat</label></p>
   <p><label><input type="radio" name="q1" value="Dog">Dog</label></p>
   <p><label><input type="radio" name="q1" value="Ant">Ant</label></p>
</fieldset>

One author might want to use this template:
<h2>{question}</h2>
{answers}

The other one prefers:
<table>
   <tr>
     <td>{question}</td>
     <td>{answers}</td>
   </tr>
</td>

While the desired results can be easily achieved with the current legend 
specification when coding manually, it is quite hard to implement with a 
template system, needing separate template variables for both the 
fieldset start and end tags, and a loop for the questions. With the 
focus of making an application as easy to use as possible (which 
includes template authoring), application authors might rather go 
without fieldset and legend, and accept the loss of structural 
consistency and accessibility as a trade-off.

I am sure this change would not break legacy content in new browsers; 
anyway I have no Idea how far it would break HTML5 content in legacy 
browsers.

Received on Thursday, 8 October 2009 13:05:55 UTC