English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Catalog

HTML keygen autofocus attribute

The keygen autofocus attribute is a boolean attribute; the autofocus attribute specifies that the <keygen> element will automatically gain focus when the page is loaded.

 HTML <keygen> tag

Online Example

Let the "Encryption" field automatically gain focus when the page is loaded:

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>基础教程网(oldtoolbag.com)</title> 
</head>
<body>
<form action="demo-frame.php" method="get">
  Username: <input type="text" name="usr_name">
  Encryption: <keygen name="security" autofocus>
  <input type="submit">
</form>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Opera, Chrome, and Safari 6 Browsers that support the autofocus attribute of the <keygen> tag

Definition and Usage

The autofocus attribute is a boolean attribute.

The autofocus attribute specifies that the <keygen> element will automatically receive focus when the page is loaded.

HTML 4.01 differences with HTML5differences

<keygen> tag is HTML5 new tags.

Differences between HTML and XHTML

In XHTML, attribute shorthand is prohibited, the autofocus attribute must be defined as <keygen autofocus="autofocus" />。

Syntax

<keygen autofocus>
 HTML <keygen> tag