X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML <option> selected Attribute

HTML option Tag Reference HTML <option> tag

Example

A drop-down list with a pre-selected option:

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="vw">VW</option>
  <option value="audi" selected>Audi</option>
</select>

Try it Yourself »

Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The selected attribute is supported in all major browsers.


Definition and Usage

The selected attribute is a boolean attribute.

When present, it specifies that an option should be pre-selected when the page loads.

The pre-selected option will be displayed first in the drop-down list.

Tip: The selected attribute can also be set after the page loads, with a JavaScript.


Differences Between HTML 4.01 and HTML5

NONE.


Differences Between HTML and XHTML

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


Syntax

<option selected>


HTML option Tag Reference HTML <option> tag

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook