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

[whatwg] Placeholder option for text input boxes

From: Garrett Smith <dhtmlkitchen@gmail.com>
Date: Sun, 5 Oct 2008 12:20:11 -0700
Message-ID: <c9e12660810051220s55974508y20127e46b068bd53@mail.gmail.com>
On Sat, Oct 4, 2008 at 5:41 PM, Andy Lyttle <whatwg at phroggy.com> wrote:
> On Oct 4, 2008, at 3:38 PM, timeless wrote:
>
>> On 10/3/08, Adrian Sutton <adrian.sutton at ephox.com> wrote:
>>>
>>>  Placeholder ... aids usability
>>


>>
>> i use quite a few browsers where javascript is disabled and in many of
>> them, clearing a text field is extremely painful (especially the phone
>> cases).
>
> The existence of a "placeholder" attribute in HTML should discourage web
> developers from using crazy Javascript hacks that don't work correctly on a
> cell phone.

Yes.


> In particular, it means NOT "faking it" by setting the value of
> the field to an obnoxious string that doesn't get cleared.

That may very well happen in a mobile browser.

> Most mobile browsers I've used switch to a text input dialog as soon as the
> control is focussed.

Opera does that.

>
> Enabling a designer to use placeholders is a moot point; they're already
> doing it, in a non-standard buggy way that breaks on your phone.  We want to
> give them semantic markup that will behave the way they want in their
> browser, while still being perfectly usable on your phone so they can quit
> using annoying hacks.  Placeholder shouldn't be "glitzy" and absolutely
> should never impede your ability to get work done; if it does, somebody
> screwed up their implementation.

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 would be possible to devise a fallback strategy by feature
detecting support for placeholderBackground style property.

>
> This is true.  Adding placeholder to HTML doesn't mean web developers will
> immediately drop their JS/CSS hacks, because existing browsers don't support
> placeholder.  But over time, as everybody upgrades their browsers and
> developers stop caring about the people still using older browsers, the
> problem should slowly fade away.
>

That's why it is useful to be able to do a feature test, to provide a
fallback strategy, where possible (and the fallback strategy should
also be feature tested).

Garrett

>
> --
> Andy Lyttle
> whatwg at phroggy.com
>
>
Received on Sunday, 5 October 2008 12:20:11 UTC

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