- From: Tab Atkins Jr. <jackalmage@gmail.com>
- Date: Thu, 16 Oct 2008 17:52:11 -0500
- To: "Daniel Glazman" <daniel.glazman@disruptive-innovations.com>
- Cc: "L. David Baron" <dbaron@dbaron.org>, www-style@w3.org
- Message-ID: <dd0fbad0810161552n499a51b3l1ff2a0de26cee17f@mail.gmail.com>
On Thu, Oct 16, 2008 at 12:57 PM, Daniel Glazman < daniel.glazman@disruptive-innovations.com> wrote: > > L. David Baron wrote: > >> Here's an idea for a future level of selectors, which I proposed a >> few days ago in >> >> http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-October/016544.html >> >> >> There are some things, like the values of form controls such as text >> inputs, that are rather like attributes (in that they have string >> values), except they're not actually attributes in the markup. The >> various forms of attribute selectors would all make sense on these >> things. >> >> The one I'm suggesting here would be a :value pseudo-attribute, >> representing the current value of a text control. (The value >> attribute in HTML represents the default value, not the current >> value.) >> >> With this, one could, for example, style inputs that don't have >> anything in them: >> >> input.mandatory[:value=""] { background: red; } >> > > In fact the initial value of the input is rarely blank: > > Please insert your family name below: > +-----------------------------------+ > | Your family name | > +-----------------------------------+ > > Localizing this would be difficult because you would need a > style rule per localization. Another way to do that could be > a pseudo-class comparing the actual value of the element with > the value of the attribute (or the textual content in some > cases) holding the initial value of the form element. > Using @value for hints, though relatively common due to the easy of it, is not a good practice, semantically or user-friendly-ly (just think about how this works on mobile browsers...). You need to clear it out when they start typing with javascript, it's not actually a valid value if the user contrives to submit it with that value, etc. There was some discussion just a week or two ago on the whatwg about a @hint attribute on <input type="text"> and <textarea> that would display text as long as the control was empty and not focused, and this value would never be submitted. @David Baron: The hint action can be done just as well with :empty:not(:focus). Is there a reasonable use-case that :empty doesn't solve equally well? ~TJ
Received on Thursday, 16 October 2008 22:52:46 UTC