HTML - <input type="checkbox">
The HTML input element <input type="checkbox">
is an input element to enter an array of different values. The value attribute is used to define the value submitted by the checkbox. The checked attribute is used to indicate whether this item is selected. The indeterminate attribute is used to indicate that the checkbox is in an indeterminate state (on most platforms, this draws a horizontal line across the checkbox).
Example
<label><input type="checkbox" id="cbox1" value="first_checkbox"> This is the first checkbox</label><br> <input type="checkbox" id="cbox2" value="second_checkbox"> <label for="cbox2">This is the second checkbox</label>
This creates two checkboxes, which look like this:
Description
The HTML input element <input type="checkbox">
is an input element to enter an array of different values. The value attribute is used to define the value submitted by the checkbox. The checked attribute is used to indicate whether this item is selected. The indeterminate attribute is used to indicate that the checkbox is in an indeterminate state (on most platforms, this draws a horizontal line across the checkbox).
Attributes
Includes the Global Attributes.
Name | Version | Description |
---|---|---|
checked |
When the value of the type attribute is |
|
value |
The initial value of the control. If omitted, the result of getting the value property of the element will be the string "on". Note that when reloading the page, Gecko and IE will ignore the value specified in the HTML source, if the value was changed before the reload. |
Browser Compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.7 or earlier) | 2 or earlier | 1.0 | 1.0 |
type=checkbox | 1.0 | 1.0 (1.7 or earlier) 3.6 (1.9.2) for indeterminate value |
2 | 1.0 | 1.0 |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | (Yes) | 4.0 (2.0) | (Yes) | (Yes) | (Yes) |
type=checkbox | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
Specifications
Specification | Status | |
WHATWG HTML Living Standard The definition of '<checkbox>' in that specification. |
Living Standard | |
HTML5 The definition of '<checkbox>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<checkbox>' in that specification. |
Recommendation |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/html/element/input/checkbox