[whatwg] required attribute in label

This could be another way to solve the same problem:

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

However, the above does not work on IE6 (attribute selectors).

So the id/class suggested by Chris is actually the most cross-browser
solution.

Diego


On Sat, Aug 21, 2010 at 3:26 PM, Chris Cressman <chris at chriscressman.com>wrote:

> > Why not make "required" an acceptable attribute for the label element?
>
> The class or title attribute can solve your problem:
>
> <label class="required">
> label.required:after {content:"*"}
>
> <label title="required">
> label[title~="required"]:after {content:"*"}
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100821/a75cf8c8/attachment-0001.htm>

Received on Saturday, 21 August 2010 07:07:13 UTC