Please check out my jsfiddle
http://jsfiddle.net/WK2N3/1/
How can I make this on autofocus like it is for chrome, safari, opera and firefox for IE?
You will have to rely on javascript to do this, since html5 autofocus is not supported in IE. There is a good blog post about it here : http://www.html5tutorial.info/html5-autofocus.php
Basically, you first check if the attribute is supported, and then use javascript to manually focus in said input using the focus()
method if it is not.
You can try this.
setTimeout(function() { document.getElementById('myInput').focus(); }, 10);
for more detail AutoFOcusIE
autofocus in IE is is just
<input type="text" id="searchbar" autofocus />
not
<input type="text" id="searchbar" autofocus="autofocus"/>
See http://msdn.microsoft.com/en-us/library/windows/apps/hh441087(v=vs.85).aspx for more info.
Usually I use jQuery:
$('input').focus()
Live example: http://jsfiddle.net/simply_simpy/eb4JJ/5/
Here's a one-liner (well, one line of actual logic) that uses jQuery to make autofocus work in IE. It bails out if the focus is already set--in other words, in any HTML5-capable browser.
$(function() {
$('[autofocus]:not(:focus)').eq(0).focus();
});
I explained how it works in my blog. And here is an updated jsFiddle that works in IE.