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

Re: Styling HTML placeholder attribute

From: Brad Kemper <brad.kemper@gmail.com>
Date: Thu, 24 Jan 2013 12:49:30 -0800
Message-Id: <82C55D7A-59AD-4DDA-BA20-426E0641059B@gmail.com>
Cc: "Tab Atkins Jr." <jackalmage@gmail.com>, Arron Eicholz <Arron.Eicholz@microsoft.com>, Sylvain Galineau <sylvaing@microsoft.com>, Mounir Lamouri <mounir@lamouri.fr>, www-style list <www-style@w3.org>, "Lea Verou (leaverou@gmail.com)" <leaverou@gmail.com>
To: Philip Walton <philip@philipwalton.com>
On Jan 24, 2013, at 12:05 PM, Philip Walton <philip@philipwalton.com> wrote:

> Obviously it would be terribly confusing, but has the option of both pseudo-class and pseudo-element been discussed?
> 
> `input:placeholder` would be used to describe an input element whose placeholder is visible and `input::placeholder` would be used to style the placeholder.

I agree with Sylvain that the name is what is leading to thinking about placeholder as an element-like thing that can be hidden or shown, when really it is just a state that causes the text in the box to be something that was not in the starting 'value' attribute and not typed by the user. To select it, you'd have to wrap that range of text in some sort of span and then hide it when the state changed due to typing or pasting, and that just seems like an unnecessary extra step that complicates the simple model of an input with some text in it. . 


> The spec specifically defines placeholders as only existing when there is no text in the input,

Which spec?

> but in my mind I've always wanted placeholders to double as type-ahead hint text as well.
> 
> If something like this were ever allowed in the future (input text and placeholder text being shown at the same time) then the color property of `input:placeholder` clearly couldn't apply to the placeholder text. It seems like using the color property to refer to both is limiting.

It's an interesting idea, but I don't think type-ahead text is the same thing as placeholder text. Having a second "thing" in the field that is a different color (and perhaps background-color) than other text in the field does imply a separate inline pseudo-element, so you would need something like '::text-suggestion' or something. Anyway, you wouldn't necessarily want it to be the same color as the placeholder text, either. 
Received on Thursday, 24 January 2013 20:50:10 GMT

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