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

HTML Referenzhandbuch

HTML-Tag-Übersicht

HTML: <input> autofocus Eigenschaft

Die autofocus Eigenschaft ist ein boolesches Attribut. Die autofocus Eigenschaft legt fest, dass das <input>-Element automatisch den Fokus erhalten soll, wenn die Seite geladen wird.

 HTML <input> Tag

Online-Beispiel

Wenn die Seite geladen wird, sollte das Feld name="fname" automatisch den Fokus erhalten:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> autofocus Eigenschaft - Grundlagen-Tutorial-Website(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  Vorname: <input type="text" name="fname" autofocus><br>
  Nachname: <input type="text" name="lname"><br>
  <input type="submit">
</form>
</body>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

Internet Explorer 10Firefox, Opera, Chrome and Safari support the autofocus attribute.

Note:Internet Explorer 9 and earlier versions do not support the autofocus attribute of the <input> tag.

Definition and Usage

The autofocus attribute is a boolean attribute.

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

HTML 4.01 and HTML5differences

The autofocus attribute is an HTML5 with the newly added attributes.

Differences between HTML and XHTML

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

Syntax

<input autofocus>

 HTML <input> Tag