HTML <input> atribut autofocus
Příklad
Umožněte, aby se vstupní pole „Jméno“ automaticky aktivovalo při načtení stránky:
<form action="/action_page.php">
<label for="fname">First name:</label>
<input type="text" id="fname"
name="fname" autofocus><br><br>
<label for="lname">Last
name:</label>
<input type="text" id="lname" name="lname"><br><br>
<input type="submit">
</form>
Definice a použití
Atribut autofocus
je booleovský atribut.
Je-li přítomen, určuje, že <input>
prvek by se měl automaticky aktivovat při načítání stránky.
Podpora prohlížeče
Čísla v tabulce určují první verzi prohlížeče, která tento atribut plně podporuje.
Attribute | |||||
---|---|---|---|---|---|
autofocus | 5.0 | 11.0 | 4.0 | 5.0 | 9.6 |
Syntax
<input autofocus>
HTML tag <input>