I'm new to HTML5 as begun to work with HTML5's new form input fields. When I'm working with form input fields, especially <input type="text" />
and <input type="search" />
IMO there wasn't any difference in all major browser including Safari, Chrome, Firefox and Opera. And the search field also behaves like a regular text field.
So, what is the difference between input type="text"
and input type="search"
in HTML5?
What is the real purpose of <input type="search" />
?
But it has a bad affect on yout input element, if you set
And in your css you set
It wont showup at all.
There's browser difference in action, when you type some words then keyed ESC in input
type="search"
in chrome/safari the input box will get cleared. but intype="text"
scenario, the words will not get cleared. So be careful choosing the type especially when u use it for autocomplete or search related featureRight now, there isn't a huge deal between them - maybe there never will be. However, the point is to give the browser-makers the ability to do something special with it, if they want.
Think about
<input type="number">
on cellphones, bringing up number pads, ortype="email"
bringing up a special version of the keyboard, with @ and .com and the rest available.On a cellphone, search could bring up an internal search applet, if they wanted.
On the other side, it helps current devs with css.
On some browsers, it also supports the "results" and "autosave" attributes which provides automatic "recent searches" functionality with the magnifier icon.
More info
Actually be very careful about assuming it does nothing. When you go to style inputs with the type search they have certain attributes that cannot be changed. Try to change the border on one and you will find it quite impossible. There are several other disallowed CSS attributes, check out this for all the details.
Also as mentioned by Jashwant there's the result attribute, though it doesn't work very well unless you also include the autosave attribute. The drop down will not work in most browsers, however, so use at your own peril.
It depends on the programmers point of view, a programmer can easily determine the purpose of the input by looking on the type and it's easy for CSS styling and for JavaScript or JQuery to verify rule in the inputs.