HTML checked attribute

Checked attribute decides that which option should be checked initially in an option list.

Example

<p>checked attribute gives default value to the input</p>
 <input type="radio" name="gender" value="Male">Male
 <input type="radio" name="gender" value="Female" checked>Female
 <input type="radio" name="gender" value="Other">Other
Try </>

href attribute values

It is a boolean attribute. The presence of this attribute checks radio button or input option initially.

Related Tags

The tags that support checked attribute are given below.

<input> tag

input tags represents an input field in a form. checked attribute should be used when 'radio' or 'checkbox' are the types of input element.

In the above example, the type of input control is 'radio'.

In the following example , the type of input control is 'checkbox'.

Example

<input type="checkbox" name="gender" value="Male">Male
<input type="checkbox" name="gender" value="Female" checked>Female
<input type="checkbox" name="gender" value="Other" >Other
Try</>

Related Pages

You can visit type attribute of input tag. type attribute indicates the type of data in input field.



Was this article helpful?

 

Email:

Message:

Get the newsletter