W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2008

[whatwg] Placeholder option for text input boxes

From: L. David Baron <dbaron@dbaron.org>
Date: Sun, 5 Oct 2008 13:07:45 -0700
Message-ID: <20081005200745.GA21866@pickering.dbaron.org>
On Sunday 2008-10-05 12:20 -0700, Garrett Smith wrote:
> But what if the designer wants to use an image?
> 
> <input type="search" placeholder="ybang.gif">
> 
> Would display the text:
> 
> "bang.gif"
> 
> - not the binary resource of the image. In some cases, designers or
> marketing will want an image there.  Maybe some ui css would be a
> possibility:
> 
> placeholder-background: url(bang.gif) no-repeat center;
> 
> This could be implemented by browsers so developers could have a
> placeholder and, where supported, a placeholder-background.

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.)

-David

-- 
L. David Baron                                 http://dbaron.org/
Mozilla Corporation                       http://www.mozilla.com/
Received on Sunday, 5 October 2008 13:07:45 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:06 UTC