HTML checked Attribute
The HTML checked attribute specifies that an <input> element must be checked when the page loads. See how you can use this attribute on the <input> element.
The HTML checked attribute is a boolean attribute and specifies that an <input> element must be checked when the page loads.
You can use this attribute only on the <input> element (<input type="checkbox"> and <input type="radio">).
It is also possible to set the checked attribute after the page loads, with JavaScript.
Syntax
<input type="checkbox|radio" checked>
<input type="checkbox|radio" checked="checked">Example of the HTML checked attribute:
HTML checked Attribute
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h2>HTML Form Example</h2>
<form action="/form/submit" method="post">
<input type="radio" name="game" value="football" checked /> Football
<input type="radio" name="game" value="basketball" /> Basketball
<input type="submit" value="Submit" />
</form>
</body>
</html>Practice
Practice
What does the HTML 'checked' attribute do?