W3C home > Mailing lists > Public > www-style@w3.org > January 2013

RE: Styling HTML placeholder attribute

From: Sylvain Galineau <sylvaing@microsoft.com>
Date: Tue, 22 Jan 2013 20:23:07 +0000
To: Tab Atkins Jr. <jackalmage@gmail.com>
CC: Mounir Lamouri <mounir@lamouri.fr>, www-style list <www-style@w3.org>
Message-ID: <3C4041FF83E1E04A986B6DC50F0178291BF49B49@TK5EX14MBXC221.redmond.corp.microsoft.com>

[Tab Atkins Jr.:]
> 
> It's been explored in past threads on the matter.  
Links? I don't recall this being settled one way or the other.

> Basically, a pseudo-
> element lets you achieve the intended placeholder appearance in a more
> reliable way.

Can you elaborate on scenarios that are less reliable in pseudo-class based
implementations? Given that we have implementations, examples are best.

> 
> Assuming standard <input> coloration (black text on white background), we
> want the placeholder to have gray text.  More generally, we want the
> placeholder to be a lighter, less saturated color than the real text.
> 
> Using a :placeholder pseudo-class, the best we can do is set the 'color'
> property itself to the gray we want.  This works badly when an author
> changes the 'background-color' of their input, as the gray may get set
> against a background-color that produces insufficient contrast.  Even if
> the gray is still sufficient contrast, the author's desired 'color' might
> not line up with gray.
> 
> Using a ::placeholder pseudo-element, we can instead set 'opacity'
> such that it produces the gray we want given typical coloration.  If the
> author changes the input's coloring to use different 'color' and
> 'background-color' values, it will still do what we want, and produce a
> lighter, less saturated version of whatever that color is.
> 
> So, overall, the pseudo-element has a higher chance of maintaining
> accessibility, and of matching the author's intent.

I don't follow this reasoning. If :placeholder is a state of the element
what prevents the author from using the exact same style he would otherwise
apply to the pseudo-element? 

Again, it would help to provide an example of the problem.

> 
> ~TJ
Received on Tuesday, 22 January 2013 20:23:47 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:21:04 GMT