[whatwg] Option label, textContent and value

Mounir Lamouri mounir.lamouri at gmail.com
Tue Mar 8 07:23:44 PST 2011

On 03/08/2011 02:22 PM, Markus Ernst wrote:
> <select>
>   <option label="Label1">TextContent1</option>
>   <option label="Label2">TextContent2</option>
> </select>
> - IE 8, Opera 11 and Chrome 9 display "Label1" and "Label2"
> - Firefox 3.6 displays "TextContent1" and "TextContent2"
> Firefox's behavour seems to be contradictory to the spec, which gives
> the label attribute precedence.

It's a very old bug in Gecko:

> Furthermore, as I understand the above definitions, the spec does allow
> to specify label and value in one step in a select element:
> <select>
>   <option>This is value and label
> </select>
> But not in a datalist, as the label is taken from the textContent rather
> than from the value of the option element:
> <datalist>
>   <option value="No label here">
>   <option label="No value here">
> </datalist>

I don't understand your point. If you want to have the same behavior,
you should write the same HTML code and I believe this is what you want:
  <option>This is a value and a label</option>
  <option>This is a value and a label</option>

Here, the option inside the datalist and the one inside the select
element will have the same label and the same value.


More information about the whatwg mailing list