HTML / HTML Attributes

HTML Checked Attribute

Dec 12, 2022
2 min read
HTML checked Attribute

Definition

The checked attribute is a boolean that specifies whether the <input> control should be pre-selected.

Applicable Elements

The checked attribute can be used with the following elements:

HTML <input> checked Attribute

The <input> element is a field used in HTML Forms enabling the user input data.

The checked attribute is a boolean that specifies whether the <input> control should be pre-selected. It is used with the radio and checkbox <input> types.

Syntax

<input type="checkbox" id="name" name="name" checked>
<input type="radio" id="name" name="name" checked>

Usage

  • The checked attribute is a boolean.
  • When present, it specifies the <input> element’s control should be pre-selected.
  • It can be used with <input type="radio"> and <input type="checkbox">.
  • The checked attribute can be set with JavaScript after the page loads.
  • The checked attribute can be targeted with CSS using the :checked pseudo-class selector. For instance, you can create elaborate drop-down menus (this website uses it extensively) by targeting the checked attribute.

Values

Values can include:

  • checked

Examples

The following shows a simple form with a radio and checkbox form prefilled with a check.

<form>
  <label for="name">Checkbox:</label>
  <input type="checkbox" id="name" name="name" checked><br><br>
  <label for="name">radio:</label>
  <input type="radio" id="name" name="name" checked>
</form>

Specification

The checked HTML specification for the <input> element is as follows:

Browser Support

The checked has the following browser support:

Desktop

ChromeEdgeFirefoxIEOperaSafari
<input>YesYesYesYesYesYes
<element>YesYesYesYesYesYes

Mobile

Android WebviewChrome AndroidFirefox AndroidOpera AndroidiOS SafariSamsung Internet
<input>YesYesYesYesYesYes
<element>YesYesYesYesYesYes