"Select" element and cross-browser passing data

I've always provided value="something"

for my option

elements inside an element select

.

In this way

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

      

Now that I've done this with countries, there is a lot of extraneous data in it. I'm sure if I remember correctly that Firefox will send text between tags if the value attribute is missing.

My question is, is this behavior the norm? Can I rely on all browsers to send the innerHTML of an option element if the value attribute is omitted?

thanks

+1


a source to share


2 answers


Yes, this will work in all browsers.

As stated in the spec:



OPTION Attribute definitions

value = cdata [CS]


                This attribute defines the initial value of the control. If this attribute is not set, the initial value is set to the content of the OPTION element.

+1


a source


Hidden from W3C :

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



With that, I would think that every major standard compliant browser should accept the "value" attribute, and if not present, take the element

+1


a source







All Articles