HTML selected Attribute

HTML selected Attribute: This attribute is defined as a boolean attribute. This attribute specifies that an option should be pre-selected when the page loads. And the pre-selected option will be displayed first in the drop-down list.

HTML selected Attribute

This attribute can be applied on <option> element.

Syntax: <option selected>



Browser Support

This attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

Example: for <option> element

<!DOCTYPE html>
<html>
<body>
<select>
  <option value="html">HTML</option>
  <option value="css">CSS</option>
  <option value="java">JAVA</option>
  <option value="C" selected>C</option>
</select>
</body>
</html>

Output:

HTML selected attribute