[Javascript] accessing a <label>
Scott Reynen
scott at randomchaos.com
Tue Jun 5 10:49:34 CDT 2007
On Jun 5, 2007, at 6:18 AM, Nick Fitzsimons wrote:
> On 4 Jun 2007, at 01:38:43, Scott Reynen wrote:
>
>> On Jun 3, 2007, at 6:10 PM, Nick Wiltshire wrote:
>>
>>> If the input is directly inside the label (as it should be)
>>
>> Huh? Why? That's not how the HTML spec examples use <label>, and
>> a label containing the input it's labeling strikes me as poor
>> semantics.
>
> The HTML spec's third example does precisely that:
>
> <http://www.w3.org/TR/html4/interact/forms.html#edef-LABEL>
>
> as a demonstration of implicit association of a label with a control.
Ah, so it does. I'd missed that. Nonetheless, I would still avoid
that.
> I can't see how this technique can be said to have poor semantics.
> The semantic significance of a label is that it describes the
> expected content of an associated control, and this is just an
> implicit way of forming that association.
A tag name describes the contents of the tag, e.g. everything inside
a <p> tag is part of a paragraph, everything inside a <table> tag is
part of a table, etc. So everything inside a <label> tag should be
part of a label. An <input> is not part of a label, so I would call
an <input> inside a <label> poor semantics, just as I would call non-
tabular content inside a <table> poor semantics. But obviously the
HTML 4 authors disagree with me.
Peace,
Scott
More information about the Javascript
mailing list