English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
In web forms, the HTML element <option> is used to define the items contained within the <select>, <optgroup>, or <datalist> elements. The <option> can represent menu items in popup windows and other item lists within html documents.
Create a list with 3 A list of options selection:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML option tag usage (Basic Tutorial Website oldtoolbag.com)</title> </head> <body> <label for="tutorial_choice">Tutorials: </label> <select id="tutorial_choice"> <option value="html">HTML</option> <option value="css">CSS</option> <option value="sql">SQL</option> </select> </body> </body> </html>Test to see ‹/›
In this HTML5In the document example, we created a list of three dropdown values using the <select> tag-HTML, CSS, and SQL. These values will be displayed as a dropdown list for user selection.
IEFirefoxOperaChromeSafari
Most mainstream browsers support the <option> tag.
<option> tag defines an option (an entry) in a dropdown list.
The content in the <option> tag is used as <select> or<datalist> One element usage.
Note: The <option> tag can be used without any attributes, but you usually need to use the value attribute, which indicates the content sent to the server.
Note: This tag should be used with the select element; otherwise, it has no meaning.
Tip: If there are many list options, you can use the <optgroup> tag to group related options.
Attribute | Value | Description |
---|---|---|
disabled | disabled | Specify that this option should be disabled when the page is first loaded. |
label | text | Define the label used when <optgroup> is used. |
selected | selected | Specify that the option should be displayed as selected when it first appears in the list. |
value | text | Define the option value sent to the server. |
<option> tag supports global attributes, see the complete attribute table HTML Global Attributes.
<option> tag supports all HTML Event Attributes.