HTML <label> tag: for attribute usage -
i have quick question usage of for
attribute in <label>
tags. know should refer id
of input element label, see being used refer name
attribute of <input>
tag in html forms. valid usage?
additionally, how should label set of, say, <input type="radio">
tags? each require individual label, of course, how correctly label group form?
thanks in advance!
the label
element defined in html 4.01 for
attribute “matches field id value”. purely syntactic requirement: attribute declared type idref
, , implies html validator issues error message if value not match id
attribute value in same document. in html5, formalism different, principle same.
thus, must match id
attribute value, , enforced browsers: element won’t act label anything, functionally, requirement violated. page still work, reduced usability , accessibility. same value may appear name
attribute value, too, since such attributes have name space of own, say.
there no way “label” set of radio buttons, or other controls, in sense label
defines labels (i.e., clicking on label
element typically focuses on associated control). , no need either.
you can, , should, have heading-like caption set of radio buttons, explaining about. that’s not job label
. can use suitable heading element (e.g., h2
), example. construct designed purpose legend
element in fieldset
element. can contain brief description of radio buttons wrapped inside fieldset
.
Comments
Post a Comment