HTML checked attribute
checked
The purpose of the HTML checked attribute is to define whether a checkbox or a radio button is checked (i.e. selected).
Supported elements
HTML checked attribute supports input element.
Syntax
<input checked="value" / >
Type of value
Checked.
Value
Checked. If set, then selects the checkbox or radio button by default.
Default value
There is no default value.
Supported doctypes
HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.
Example of HTML checked attribute with input checkbox
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML checked attribute with input checkbox </title>
</head>
<body>
<form action="action.php" method="post">
<input type="checkbox" name="age" value="adult" checked="checked"/> I am above 18. <br/>
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML checked attribute with input check box.
Example of HTML checked attribute with input radio button
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Example of HTML checked attribute with radio button</title>
</head>
<body>
<form action="action.php" method="post">
<input type="radio" name="age" value="adult" checked="checked"/>I am above 18.<br/>
</form>
</body>
</html>
Result
View this example in a separate browser window
Example of HTML checked attribute with input radio button.
Previous: HTML charset attribute
Next: HTML cite attribute
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/attributes/html-checked-attribute.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics