W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2010

[whatwg] required attribute in label

From: Diego Perini <diego.perini@gmail.com>
Date: Sat, 21 Aug 2010 16:07:13 +0200
Message-ID: <AANLkTimG0VaC=6q_SAL1Y+uwOpgCi6f9oU3i_3xe0+w7@mail.gmail.com>
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

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:26 UTC