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" />
?
using input type="search" make the keybord enterkey's text show "search", which may improve user experience. however, you have to adjust the style if using this type.
Also,
Reference
Above all, it provides a semantic meaning to the
input type
.Update:
Chrome 51 removed support for the results attribute:
Visually/functionally, 2 differences if the input type is 'search':-
The majority of functionalities are the same but 1 difference we can see using browsers is that
search
input is a little different in SAFARI and CHROME. They add "x" icon at the right side, but it's the same thing for FireFox, IE, etc.In short, no difference for Firefox, IE, Opera, only for safari and chrome. RAW Paste Data The majority of functionalities are the same but 1 difference we can see using browsers is that
search
input is a little different in SAFARI and CHROME. They add "x" icon at the right side, but it's the same thing for FireFox, IE, etc.In short, no difference for Firefox, IE, Opera, only for safari and chrome.
Bonus point:
input type="search
" has the ability to use theonsearch
attribute (although I have noticed this does NOT work in Microsofts new Edge Browser), which eliminates the need to write a customonkeypress=if(key=13) { function() }
thing.