[whatwg] required attribute in label

Eduard Pascual herenvardo at gmail.com
Sat Aug 21 12:26:12 PDT 2010


On Sat, Aug 21, 2010 at 6:18 PM, Brenton Strine <whatwg at gmail.com> wrote:
>> <label class="required">
>
> and
>
>> <input id="name1" type="text" required><span> </span>
>
> are effective, but then again this would be too:
>
> ...</label>*
>
> It just seems a shame that we have this neat attribute that indicates
> required controls, but we can't actually use it to change the
> presentation adding additional code.

Presentation issues should by addressed by CSS, not by HTML.
Actually, Diego's suggestion:
label + input[required] + span:after { content: " * "; }
Seems to be the right approach here (with current CSS selectors).
I'm not considering IE's issue with attribute selectors because your
original proposal (label[required]) would encounter the same problems.

What sense would have to mark a *label* as required? @required on
<label> is semantically wrong. And HTML should not compromise
semantics only for presentation purposes.

On a side note, keep in mind that there have been several proposals on
the CSS lists for "reversed" selectors (ie: selecting elements based
on what they contain rather than what contains them). So hopefully we
might have something like label:has(+ input[required]):after {
content: " *"; } in the future.

Just my thoughts.

Regards,
Eduard Pascual



More information about the whatwg mailing list