html tutorial - autofocus Attribute in HTML - html5 - html code - html form




Autofocus attribute in html

Learn html - html tutorial - Autofocus attribute in html - html examples - html programs

  • The autofocus attribute is a Boolean attribute.
  • The autofocus attribute particularly specifies the element should automatically focus when the HTML page is loaded.

Syntax for autofocus attribute in HTML:

<element autofocus>

Differences between HTML 4.01 and HTML5 for autofocus attribute:

HTML 4.01

  • HTML4 does not support autofocus attribute.

HTML 5

  • autofocus attribute new in HTML5.

Applies To:

Elements Attribute
<button> autofocus
<input> autofocus
<keygen> autofocus
<select> autofocus
<textarea> autofocus

Sample Coding for autofocus Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy autofocus attribute</title>
    </head>
    <body>
       First name : <input type="text" name="fname">
       E-mail : <br>
       <input type="email" name="email" autofocus>
        </body>
</html>

Code Explanation for autofocus Attribute in HTML:

autofocus Attribute Code Explanation

  1. autofocus attribute is used to enable the autofocus for the E-mail textbox.

Output for autofocus Attribute in HTML:

autofocus Attribute Tag Output

  1. The output shows that the E-mail textbox automatically focused while the page load.

Browser Support for autofocus Attribute in HTML:

Element
<form> 5.0 10.0 4.0 5.0 9.6
<input> 5.0 10.0 4.0 5.0 9.6
<keygen> yes No No 5.0 Yes
<textarea> yes 10.0 4.0 Yes Yes

Related Searches to autofocus Attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×