W3C home > Mailing lists > Public > public-whatwg@w3.org > May 2012

Re: [whatwg] Should editable elements have placeholder attribute?

From: Charles Pritchard <chuck@jumis.com>
Date: Wed, 02 May 2012 10:15:23 -0700
Message-ID: <4FA16BAB.8060500@jumis.com>
To: Ryosuke Niwa <rniwa@webkit.org>
Cc: whatwg@lists.whatwg.org, David Hyatt <hyatt@apple.com>, Adele Peterson <adele@apple.com>, Aryeh Gregor <ayg@aryeh.name>, Ojan Vafai <ojan@chromium.org>
On 5/2/12 10:08 AM, Ryosuke Niwa wrote:
> On Wed, May 2, 2012 at 10:06 AM, Ojan Vafai<ojan@chromium.org>  wrote:
>> I'm OK with having when the placeholder is displayed be up to the UA. I
>> can see that being platform specific.
>> But, we should spec when content is eligible for showing a placeholder
>> (i.e. we should define what "looks empty" means). I don't see any benefit
>> in browsers behaving differently here. This part is not platform-specific.
>> It's just hard to figure out how to spec it.
> Maybe when element.innerText or element.textContent is empty?

Is this something we might have a CSS selector for in the future?

I've previously asked about having CSS work a little more closely with 
innerHTML and textContent, but the only use case was for showing code in 
specs and tutorials, and it'd still need something like 
-webkit-text-select to work with generated content.

Such as:
code::before { content: html(); display: block; border: .1em solid black; }
<code><span>My <i>html</i> example</span></code>

That'd also have a content: text(); which would use innerText. Both 
return strings.

So we'd have a css selector of something like:

ul[text()=""] { content: attr(placeholder); }
<ul contenteditable placeholder="test"><li></li></ul>

Received on Wednesday, 2 May 2012 17:16:44 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:07:52 UTC