views:

78

answers:

2

I've always provided a value="something" for my option elements within a select element.

Like so

<select>
   <option value="true">True</option>
</select>

Now that I have made one with countries, there is a lot of extraneous data in there. I'm pretty sure if I remember correctly, that Firefox will send the text between the tags if a value attribute is not present.

My question is, is this behaviour the norm? Can I rely on all browsers sending the innerHTML of the option element if the value attribute is omitted?

Thanks

+1  A: 

Yes, this will work in all browsers.

As the specification says:

OPTION Attribute definitions

value = cdata [CS]
            This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the OPTION element.

Paolo Bergantino
Thanks Paolo! .
alex
+1  A: 

Grabbed from W3C:

value = cdata [CS] This attribute specifies the initial value of the control. If this attribute is not set, the initial value is set to the contents of the OPTION element.

With this I'd think that every major standard compliant browser should take the 'value' attribute and if it's not present take the element

victor hugo