[whatwg] The placeholder attribute

Bjartur Thorlacius svartman95 at gmail.com
Thu Sep 22 16:53:15 PDT 2011


The semantics of the placeholder and title attributes of inputs overlap  
slightly; the placeholder attribute may contain a hint to aid the user,  
while title is to contain "other advisory text." I can think of two valid  
uses of placeholder: example value, and the text "click here to type" or  
"enter search query here." The latter is obviously user interface that  
should be implemented by interactive user agents. Then there is the third  
use, use it as a title attribute (but with richer presentation).
Users might want values falling under the first to be prefixed with  
"e.g.", "for example" or equivalent - but by allowing the latter use  
forces authors to add it to all example values, rather than letting the  
user's style sheet take care of it. Thus I suggest narrowing the semantics  
of the attribute to example values, allowing for easier styling by users  
(or agents, on their behalf). The second one should have no valid  
representation. Lastly, the specification should make it clearer what the  
title attribute is appropriate for; a description of the input or format.

Also, I see no reason to suggest not rendering the text when the input is  
focused - in special on 1D devices such as speech - considering that  
JavaScript dependent sites (such as Hotmail) have placed example values in  
a small font below the input so that it can be visible while the user is  
typing, and, more importantly, after the input has been focused (whether  
automatically or manually), but before the user starts typing.

As for the argument against using the title attribute for everything that  
it would break existing sites, I do believe rendering the title attribute  
of an empty and unfocused input inside of it is an improvement over  
displaying a tooltip a second or two after the user positions a cursor  
over the input (irrespective of focus). How on Earth is anyone to think of  
doing that? Displaying the title attribute in a floating box in a margin  
when an input is focused, followed by the example value prefixed with  
"e.g." would be my preferred rendering, but that's just my opinion.

P.S. The last paragraph of the section on the pattern attribute links  
twice to <semantics.html#the-title-element>. Should it not link to  
<elements.html#the-title-attribute>?


More information about the whatwg mailing list