- From: L. David Baron <dbaron@dbaron.org>
- Date: Tue, 13 Mar 2012 08:35:01 -0500
- To: www-style@w3.org
On Tuesday 2012-03-13 07:18 +0800, Kang-Hao (Kenny) Lu wrote: > (12/03/13 2:42), Christoph Päper wrote: > > Stefan Wallin: > >> > >> My issue. I think the :empty pseudo class selector is not super > >> intuitive when it comes to form elements such as input fields. > > > > Your issue, actually, is not with the ‘:empty’ pseudo-class. You > > want a dynamic selector for the value (attribute). David Baron > > suggested a pseudo-attribute, ‘[:value]’, for this > > <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2008-October/016544.html>. In full, what I wrote was: # It seems like this belongs on the selector side of CSS, not the # property side. It's not clear to me why you chose to duplicate only # the background-* properties, but no others. # # I think something more like the following would work better: # input[:value=""] { background: url(bang.gif) no-repeat center; } # perhaps with a default of: # input[:value=""] { contents: attr(placeholder); } # # (The value attribute doesn't dynamically reflect the value of the # input. However, it seems reasonable to want to style based on the # current value; we already have the :checked pseudo-class for that # for some form controls.) > > The CSS WG wiki <http://wiki.csswg.org/spec/selectors4> currently lists > > the ‘::value’ pseudo-element from the UI module > > <http://dev.w3.org/csswg/css3-ui/#pseudo-value> as an alternative, but > > that’s wrong I think, because you cannot do attribute value comparison > > (‘=’, ‘^=’, ‘$=’, ‘*=’ …) with that. > > The wiki has > > [[ > dynamic values selector - > already handled by ::value pseudo-element in CSS3-UI. > ]] > > . I am not quite sure what it means. '::value:empty' maybe? Would > 'input::value:empty' be too long to be useful? I'll note that selectors4 > has this paragraph: > > # Syntactically, a pseudo-element may be followed by any combination > # of the user action pseudo-classes. Whether these pseudo-classes can > # match on the pseudo-element depends on the pseudo-class and > # pseudo-element's definition: unless otherwise-specified, none of > # these pseudo-classes will match on the pseudo-element. > > so I guess we might be able to say :empty applies to ::value. Maybe. I don't see how the ::value pseudo-element solves any of the same problems that a :value pseudo-attribute would solve. They're different concepts; the pseudo-element allows styling the value and the pseudo-attribute allows selecting on it. -David -- 𝄞 L. David Baron http://dbaron.org/ 𝄂 𝄢 Mozilla http://www.mozilla.org/ 𝄂
Received on Tuesday, 13 March 2012 13:35:39 UTC