<option>


HTML <option> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>
  
</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

Most mainstream browsers support< option> tag.


Tag definition and usage instructions

The <option> tag defines an option (one item) in the drop-down list.

The content in the <option> tag is used as an element of <select> or <datalist>.


Tips and Notes

Note: The <option> tag can be used without any attributes, but you usually need to use the value attribute, which indicates Content sent to the server.

Note: Please use this tag in conjunction with the select element, otherwise this tag is meaningless.

Tip: If there are many options in the list, you can use the <optgroup> tag to combine related options.


Properties

PropertiesValueDescription
disableddisabledSpecifies that this option should be disabled on first load.
labeltext Defines the label used when <optgroup> is used.
selectedselected Specifies that the option appears selected (when first displayed in the list).
valuetext Defines the option value sent to the server.


Global attributes

<option> tag supports global attributes, view the complete attribute table HTML global attributes.


Event attributes

<option> tag supports all HTML event attributes.