HTML <input> Tag with the 'checked' Attribute

<form name="myForm" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="checkbox" name="Checkbox1">
<input type="checkbox" name="Checkbox2" checked>
<input type="checkbox" name="Checkbox3">

<button>Submit</button>
</form>

The above example demonstrates usage of the <input> element with the checked attribute.

The checked attribute allows have the input control already checked when the page loads.

The checked attribute can also be used on radio buttons. Like this:

<form name="myForm2" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<label><input type="radio" name="favColor" value="red">Red</label>
<label><input type="radio" name="favColor" value="green">Green</label>
<label><input type="radio" name="favColor" value="blue" checked>Blue</label>

<button>Submit</button>
</form>

The checked attribute is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either checked or checked="checked").

Possible values:

  • [Empty string]
  • checked