option selected Attribute - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:option

Description

The selected attribute is a boolean attribute to set if an option should be pre-selected when the page loads.

In XHTML, the selected attribute must be defined as <option selected="selected">.

The following code shows how to create A drop-down list with a pre-selected option:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<select>
  <option value="css">CSS</option>
  <option value="java">Java</option>
  <option value="python">Python</option>
  <option value="a" selected>A</option>
</select><!--from   w ww  .  j a  va 2  s . com-->

</body>
</html>

Related Tutorials