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

HTML Reference Manual

HTML Tag Reference

HTML: <input> checked attribute

This article introduces the HTML input checked attribute, which is a boolean attribute that specifies that the <input> element should be pre-selected (checked) when the page is loaded.

 HTML <input> etichetta

Online Example

HTML form with a checkbox selected by default:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> checked attribute - Basic Tutorial Website (oldtoolbag.com)</title>
<body>
<form action="action_page.php" method="get">
  <input type="checkbox" name="vehicle" value="Bike">Mountain bike<br>
  <input type="checkbox" name="vehicle" value="Car" checked>Automobile<br>
  <input type="submit" value="Submit">
</form>
</body>
</html>
Prova a vedere ‹/›

Compatibilità dei browser

IEFirefoxOperaChromeSafari

Tutti i browser mainstream supportano l'attributo checked.

Definizione e uso

L'attributo checked è un attributo booleano.

Se presente, specifica che l'elemento <input> deve essere selezionato (selezionato) al caricamento della pagina.

L'attributo checked può essere usato con <input type="checkbox"> e <input usato insieme a type="radio">.

L'attributo checked può anche essere impostato tramite codice JavaScript una volta che la pagina è stata caricata.

Differenze tra HTML 4.01 e HTML5

Nessuna.

Differenze tra HTML e XHTML

In XHTML, è proibita la abbreviazione degli attributi, l'attributo checked deve essere definito come <input checked="checked" />.

Sintassi

<input checked>
 HTML <input> etichetta