checked

Jump to: navigation, search

checked

This article is Almost Ready.


W3C Candidate Recommendation

Summary

Indicates the initial state of a checkbox or radio button.


Applies to html/elements/input

The checked attribute can be used to specify what the visual or initial state of an input element is. It's often used to toggle an element through JavaScript.

Valid values are "checked" and nothing. The attribute is never required.

Compatibility

There is no data available for topic "html", feature "checked". If you think that there should be data available, consider opening an issue.

Examples

View live exampleThis example shows a set of radio buttons with one checked.

HTML


<form role="form">
	

Radio buttons

<label for="rad1">Option 1</label> <input type="radio" name="rad1"> <label for="rad2">Option 2</label> <input type="radio" name="rad2" checked> <label for="rad3">Option 3</label> <input type="radio" name="rad3"> <label for="rad4">Option 4</label> <input type="radio" name="rad4"> </form>

Notes

Remarks

Check boxes that are not selected do not return their values when the form is submitted. A user can select a radio button only if the button has a name. To clear a selected radio button, a user must select another button in the set. Windows Internet Explorer 8 and later. In IE8 Standards mode, parsing operations on the checked content attribute always affect both the checked content attribute and defaultChecked Document Object Model (DOM) attribute. For example, removeAttribute('checked') sets both checked and defaultChecked to false. Similarly, setAttribute('checked', 'checked') sets both DOM attributes to true (as if the element was being re-parsed) For more information on IE8 mode, see Defining Document Compatibility. Internet Explorer 8 and later. In IE8 mode, the defaultChecked DOM attribute reflects the value of the checked content attribute.


Related specifications

Specification Status Related Changes
HTML5 W3C Candidate Recommendation

See also

Related articles

HTML










  • checked









































… further results


External resources

Attribution

This article contains content originally from external sources.

Portions of this content come from the Microsoft Developer Network: [Windows Internet Explorer API reference Article]