What is the proper way to check and uncheck a checkbox in HTML5?

B Seven picture B Seven · Oct 3, 2012 · Viewed 232.1k times · Source

Looked at the HTML spec, but couldn't make heads or tails of it: http://www.w3.org/TR/html5/the-input-element.html#attr-input-checked

What is the correct way to check a checkbox in HTML (not dynamically)?

checked="true"
checked="checked"

What is the correct way to uncheck a checkbox?

<input type="checkbox" /> with no checked attribute
checked="false"
checked="none"

Where to check the HTML specification to check/uncheck a checkbox?

Answer

valentinas picture valentinas · Oct 3, 2012
<input type="checkbox" checked="checked" />

or simply

<input type="checkbox" checked />

for checked checkbox. No checked attribute (<input type="checkbox" />) for unchecked checkbox.

reference: http://www.w3.org/TR/html-markup/input.checkbox.html#input.checkbox.attrs.checked