HTML input checkbox

HTML input tag with type=checkbox can be used to create check box in html. It can also be nested in label tag. When inside label tag, it can be toggled by clicking anything which is part of label.

Attributes

Some HTML attributes (in addition to global attributes) for input checkbox are

  • checked – The the checkbox is checked initially
  • disabled – The checkbox is disabled
  • value – The value which is sent to server as form data when checked. No value is sent when unchecked.

Example – input checkbox

<form>
<input type="checkbox" name=name1 value="value1" checked><br>
<input type="checkbox" name=name2 value="value2" checked disabled>
</form>
refresh

Example – input checkbox with label

<form>
Click wither on "Label1" or checkbox itself.<br>
<label>Label1
  <input type="checkbox" value="value1" checked>
</lable>
</form>
refresh

Related

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit

Comments

Click here to write/view comments