English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The selected attribute is a boolean attribute. If present, it specifies that an option should be pre-selected when the page is loaded. The pre-selected option will be displayed first in the dropdown list.
Dropdown list with a pre-selected option:
<!DOCTYPE html> <html> <head> <title>HTML:<option selected attribute - 基础教程网(oldtoolbag.com)</title> </head> <body> <select> <option value="PHP">PHP</option> <option value="HTML">HTML</option> <option value="C++">C++</option> <option value="GOLANG" selected>GOLANG</option> <option value="JAVA">JAVA</option> </select> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the selected attribute.
The selected attribute is a boolean attribute.
If present, it specifies that an option should be pre-selected when the page loads.
Pre-selected options will be displayed first in the drop-down list.
Tip: You can also set the selected attribute using JavaScript after the page has loaded.
None.
In XHTML, attribute shorthand is prohibited, the selected attribute must be defined as <option selected="selected">.
<option selected>HTML <option> tag