Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <option> selected Attribute

The selected attribute on an <option> tag specifies that the dropdown option is selected, i.e. highlighted.

If used in a multi-select dropdown, only the last option will be selected.

Example

#

A selected attribute on an <option> element.
Of the countries, Sweden is selected.

<select>
  <option label="">-- Select a Country --</option>
  <option value="denmark">Denmark</option>
  <option value="sweden" selected>Sweden</option>
  <option value="norway">Norway</option>
</select>

Using selected

The selected attribute specifies a selected (highlighted) option in a dropdown control.

When the page loads, this will be the selected item.

In a standard, single-select dropdown control, only one option can have a selected attribute.

With multiple options selected, only the last option with this attribute will be selected.

However, a multi-select dropdown control, with the multiple attribute, can have multiple options selected.


Syntax

<option selected>

Browser support

Here is when selected support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
8.0 Mar 2009
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

 Back to <option>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides