[whatwg] what use-case is there for the name-attribute on a fieldset?

Ian Hickson ian at hixie.ch
Fri Dec 21 15:37:25 PST 2012

On Fri, 21 Dec 2012, Evert Van dansen wrote:
> Recently I noticed that HTML5 allows the name-attribute on a fieldset. 
> This was not the case in HTML4.0.1.
> I did some tests and noticed that this name is *not* part of the POSTed 
> data when submitting a form? So I was wondering when and for what 
> purpose this name-attribute should or could be used?

On Fri, 21 Dec 2012, Anne van Kesteren wrote:
> <!DOCTYPE html>
> <form><fieldset name=hah></fieldset></form>
> <script>alert(document.forms[0].hah)</script>

What Anne is saying here is just that this is what browsers already 
implemented. Specifically, forms but <fieldset> elements in their 
.elements array.

(When writing the contemporary HTML spec, I mostly ignored the HTML4 
spec, and based the new spec on what browsers did.)

On Fri, 21 Dec 2012, Evert Van dansen wrote:
> I am sorry, perhaps I misunderstand, but I do not see what the advantage 
> is over using "regular" hooks (like id) in this case? Surely adding the 
> name-attribute must have been a decision based on something specific?

There's no advantage. In fact it is an entirely useless feature as far as 
I can tell. :-)

The name, type, willValidate, validity, validationMessage, checkValidity, 
and setCustomValidity features on fieldset are only there so that you can 
enumerate all the controls in a form.elements array and be confident that 
they will all have all those features, so you don't have to keep checking 
that it's not a fieldset each time.

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