HTML 5 Search Input Text Field

Posted in Featured Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

New to HTML 5, is the search input field. We of course have the input field long ago. But HTML5 added add the new type attribute type=”search” which you can use as follow…

code for search-input field

code for search-input field

See live code here.

Note that HTML5 also supports the placeholder attribute.

And we see how this works in Chrome 8 …

placeholder text in chrome

placeholder text in chrome

See the placeholder text is shown in a lighter color. And when we start typing, the placeholder text disappears and an cancel “X” icon appears.

search input field with cancel button in chrome

search input field with cancel button in chrome

Traditionally, this kind of functionality is done via Javascript or JQuery. And you can still use that for browsers that do not support HTML5.

But for browser that support HTML5, you get all that built in for you by the browser.

Reference to HTML 5 Search Input Field

W3C working draft document of HTML 5 Search input field