html tutorial - checked Attribute in HTML - html5 - html code - html form

Learn html - html tutorial - Checked attribute in html - html examples - html programs
- The checked attribute used to set that the checkbox or radiobutton should be checked while the page loads.
- The checked attribute is a Boolean attribute.
- The checked attribute can also be applied after the page load, with a JavaScript.
Syntax for checked attribute in HTML:
<input type="checkbox" value =”text” checked>
Applies To:
Elements | Attribute |
---|---|
<input> | checked |
Sample Coding for checked Attribute in HTML:
Tryit<!DOCTYPE html>
<html>
<body>
<form>
<input type="checkbox" name="tutorial" value="HTML" checked>I learn HTML
<br>
<input type="checkbox" name="tutorial" value="CSS" checked>I learn CSS
<br>
<input type="checkbox" name="tutorial" value="PHP" >I learn PHP
</form>
</body>
</html>
Code Explanation for checked Attribute in HTML:

- <form> tag is used to design a form for user input.
- <input>tag used to specify an input field to get input from the user.
- type attribute is used to set the input field as checkbox.
- name attribute is used to set the name for the checkbox.
- value attribute is used to set the value for the checkbox.
- Checked attribute used to set the checkbox in selected (checked) state.
Output for checked Attribute in HTML:

- The output shows that the checkboxes “I learn HTML & I learn CSS”in selected state by default on page loads.
Browser Support for checked Attribute in HTML:
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
1.0 | 2.0 | 1.0 | 1.0 | 1.0 |