Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

HTML5 <option> tag


May 03, 2021 HTML5


Table of contents


Definitions and usages

HTML5 - the option ; label defines an option in the drop-down list.

The difference between HTML 4.01 and HTML 5

In HTML 5, the label is also used in the new element, the lt;datalist.

Tips and comments

Note: The label can be used without any property, but usually requires the value property, which defines the data sent to the server.

Note: Please use it in conjunction with the hashtags . Elsewhere, the label is meaningless.

Example

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

Property

Property Value Describe 4 5
disabled disabled It is stated that this option should be disabled on first load. 4 5
label text Defines the labels that are used when using slt;optgroup. 4 5
selected selected The specified options (when first displayed in the list) are displayed as selected. 4 5
value text Define the option values that are sent to the server. 4 5

The standard property

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, 
lang, ref, registrationmark, tabindex, template, title

For a complete description, visit standard properties in HTML 5.

The event property

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, 
ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, 
ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, 
onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, 
onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

For a complete description, visit event properties in HTML 5.