Which Attribute Is Used to Preselect Checkbox?

The checked attribute is a boolean attribute. When present, it specifies that an <input> element should be pre-selected (checked) when the page loads. The checked attribute can be used with <input type="checkbox"> and <input type="radio"> .

How do I select a checkbox?

Checking if a checkbox is checked
  1. First, select the checkbox using the selecting DOM methods such as getElementById() or querySelector() .
  2. Then, access the checked property of the checkbox element. If its checked property is true , then the checkbox is checked; otherwise, it is not.

What is a checked attribute?

The checked attribute in HTML is used to indicate whether an element should be checked when the page loads up. It is a Boolean attribute. Note: It can be used with <input> element only where type is either “checkbox” or “radio”.

Sarah Jenkins

Sarah Jenkins

Senior Technology Editor & AI Specialist

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.