HTML 5 Placeholder Text
HTML 5 Placeholder Text
Join the DZone community and get the full member experience.Join For Free
Learn how Crafter’s Git-based content management system is reinventing modern digital experiences.
Previously, this blog posted an overview of HTML 5. Let's have a closer look at one of the more useful HTML5 features: placeholder text. Placeholder text is a short hint intended to help the user understand what their data entry should be. It is not default text.
<form action="myform"> <label for="first_name">First name:</label> <input name="first_name" placeholder="Your first name..." type="text"/> </form>
Placeholder text has some real benefits. It means you are conveying more information to the user but not taking up anymore valuable real estate space on the page. Now, it is fair to say that there are some very popular GUIs that don't use placeholder text. For example, the login screen for gmail does not.
This begs the question when from a usability perspective when does it make sense to use it and when is it best avoided? Let's think about the gmail case a bit more and that helps answer the question.
By default, the gmail Username textbox gets focus when you arrive at www.gmail.com. This makes sense. The Username textbox is the smart staring point for this page. It's the logical place for the user to start their interaction. Now, when a textbox has focus any placeholder text it has always gets wiped. Otherwise, the user would be seeing a mixture of what they are typing and what the placeholder text was. That would just be horrible! So, since the username textbox has default focus for gmail.com it makes sense that when you arrive, the username textbox is blank. How about the case when the user types nothing in the username textbox and shifts the focus to something else? Would the arrival of placeholder text add meaning or confuse the user? I'd argue it would confuse them. Aside from the sudden flicker being an irration, the user could think they did something to cause the text to be put there. It will confuse rather than elucidate! As for the password field, well they generally don't have placeholder text - for obvious reasons. So gmail is being smart here. There is no placeholder text but for logical reasons.
So placeholder text is great but there's the question of when it should be and shouldn't be used should not be avoided.
Now, let's dig a bit further into the usability. The W3C spec states that the: "
placeholderattribute should not be used as an alternative to a
label". I'd also suggest that the placeholder text should not repeat the label. What's the point in saying the same thing twice? There's no point in duplication, but there is nearly always a case for elucidation. A good example is the firefox searchbar. This is the text bar found in the top right corner of the Firefox window that can be used to search popular search engines without the user having to access them directly. A number of different search engines can be selected. In all cases, there is icon for the engine which acts as a label for the search engine. There is also placeholder text in the search textbox ajacent to the icon label. This elucidates what the label icon is identifying. For example, for Wikipedia we see, the Wikipedia icon and then the placeholder text: Wikipedia (en)
What's really clever is here is the use the very efficient use of real estate. The icon is very small and in case it is not clear it means Wikipedia, the placeholder text elucidates the matter. We see the same if Google is selected.
1. HTML5 spec: http://dev.w3.org/html5/spec/Overview.html
2. HTML5 placeholder spec: http://dev.w3.org/html5/spec/Overview.html#the-placeholder-attribute
3. Site to test your HTML5 browser support: http://html5test.com/
4. Site to test your browser support for input type attribute support: http://miketaylr.com/code/input-type-attr.html
Opinions expressed by DZone contributors are their own.