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



Checked attribute in html

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:

 checked Attribute Code Explanation

  1. <form> tag is used to design a form for user input.
  2. <input>tag used to specify an input field to get input from the user.
  3. type attribute is used to set the input field as checkbox.
  4. name attribute is used to set the name for the checkbox.
  5. value attribute is used to set the value for the checkbox.
  6. Checked attribute used to set the checkbox in selected (checked) state.

Output for checked Attribute in HTML:

checked Attribute Tag Output

  1. 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

Related Searches to checked Attribute in html