English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <option> tag

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.

Online Example

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.

Browser Compatibility

IEFirefoxOperaChromeSafari

Most mainstream browsers support the <option> tag.

Definition and Usage of Tags

<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.

Tips and Notes

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

AttributeValueDescription
disableddisabledSpecify that this option should be disabled when the page is first loaded.
labeltextDefine the label used when <optgroup> is used.
selectedselectedSpecify that the option should be displayed as selected when it first appears in the list.
valuetextDefine the option value sent to the server.

Global Attributes

<option> tag supports global attributes, see the complete attribute table HTML Global Attributes.

event attributes

<option> tag supports all HTML Event Attributes.