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.
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook