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

HTML reference manual

HTML tag大全

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> etiqueta

Online example

HTML form with a checkbox pre-selected:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> checked attribute - base tutorial website(oldtoolbag.com)</title>
<body>
<form action="action_page.php" method="get">
  <input type="checkbox" name="vehicle" value="Bike">Bicicleta de montanha<br>
  <input type="checkbox" name="vehicle" value="Car" checked>Carro<br>
  <input type="submit" value="Submit">
</form>
</body>
</html>
Teste e veja ‹/›

Compatibilidade do navegador

IEFirefoxOperaChromeSafari

Todos os navegadores mainstream suportam a propriedade checked.

Definição e uso

A propriedade checked é um atributo booleano.

Se existir, especifica que o elemento <input> deve ser pré-selecionado (selecionado) ao carregar a página.

A propriedade checked pode ser usada com <input type="checkbox"> e <input type="radio"> juntas.

A propriedade checked também pode ser configurada após a carga da página pelo código JavaScript.

HTML 4.01 Com HTML5Diferenças

Nenhuma.

Diferenças entre HTML e XHTML

No XHTML, a abreviação de atributos é proibida, a propriedade checked deve ser definida como <input checked="checked" />。

Sintaxe

<input checked>
 HTML <input> etiqueta