[whatwg] required attribute in label

This question is sort of CSS related, but I think it's worth bringing up
here, assuming it hasn't already been discussed.

The first thing I wanted to do with the "required" attribute when I started
playing with it is to use the CSS :after pseudo-element to add an asterisk
after every required input:

<style>
[required]:after {content:"*";}
</style>
<label for="name1">Name</label>
<input id="name1" type="text" required>

However, it seems that since input is an empty element, the content cannot
be added after. My next thought was to somehow get at that "required" state
via the label for it, but that seems a bit complicated. Then I realized the
asterisk really ought to be after the label, not the input--which is perfect
since the label is not an empty element. However, "required" is for input
only.

Why not make "required" an acceptable attribute for the label element? It
could be done so that the "required" attribute can be on either just the
input or both the input and the label. Ideally, it could be put in the label
element only, and that would be transfered down to the input to which it is
connected automatically, so putting the "required" attribute on the label
automatically makes all attributes to which the label is connected required
as well.

Brenton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100820/212c713d/attachment.htm>

Received on Friday, 20 August 2010 23:33:01 UTC