Besides the fact that only IE7+ supports it, why would you use something such as this example? Namely:
<select> <option label="Volvo">Volvo (Latin for "I roll")</option> <option label="Saab">Saab (Swedish Aeroplane AB)</option> </select>
After all, 'Latin for "I roll"' and 'Swedish Aeroplane AB' are lost (i.e., only remain in the source code).
The HTML <label> for Attribute is used to specify the type of form element a label is bound to. Attribute Values: It contains the value i.e element_id which specify the id of the element that the label is bound to.
Definition and Usage The label attribute specifies a shorter version of an option. The shorter version will be displayed in the drop-down list.
Definition and Usage. The <option> tag defines an option in a select list. <option> elements go inside a <select>, <optgroup>, or <datalist> element. Note: The <option> tag can be used without any attributes, but you usually need the value attribute, which indicates what is sent to the server on form submission.
The value attribute specifies the value to be sent to a server when a form is submitted. The content between the opening <option> and closing </option> tags is what the browsers will display in a drop-down list.
In that example, the long text will be sent to the server when the form is submitted.
Given the existence of the value attribute, it is redundant.
As per the definition of the option tag by the w3c :
"This attribute allows authors to specify a shorter label for an option than the content of the OPTION element. When specified, user agents should use the value of this attribute rather than the content of the OPTION element as the option label."
David's answer is pretty good, I just wanted to add a link to the official definition. :D
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With