HTML <input> checkedAttribute

HTML input 标签参考手册HTML <input> Tag

Examples

HTML form with a pre-selected checkbox:

<form action="demo_form.php" method="get">
<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car" checked> I have a car<br>
<input type="submit" value="提交">

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the checked attribute.


Definition and Usage

The checked attribute is a boolean attribute.

The checked attribute specifies that an <input> element should be pre-selected when the page loads.

The checked attribute applies to <input type="checkbox"> and <input type="radio">.

The checked attribute can also be set via JavaScript code after the page loads.


Differences between HTML 4.01 and HTML5

None.


Differences between HTML and XHTML

In XHTML, attribute minimization is forbidden, and the checked attribute must be defined as <input checked="checked" />.


Syntax

<input checked>


HTML input 标签参考手册HTML <input> Tag Other Extensions