I’m wondering, is there a productive reason for doing this:
<option value="My Value">My Value</option>
As opposed to this:
<option>My Value</option>
In other words, specifically specifying a value attribute, even when the value it contains is not different from the content within the option tag?
I often see the first in professionally developed software packages. Just wondering what benefits or background there is to doing the former when it doesn’t appear necessary, or if it doesn’t matter (in other words, coding style/preference).
Note, I realize there are times when this is useful, such as:
<option value="USA">United States</option>
It’s when they are the same that I’m wondering what the appropriate thing to do is.
Also, as Kyle points out, the specs say that the second form is entirely legal. So my thought is there might be other reasons for the value being there.
Even in the case where the processing code expects the same value as the displayed option, it’s often a good idea to keep the displayed text decoupled from the option’s value.
For example, if you ever want to internationalize this site, you’re probably going to want to be able to translate the text that is displayed, but not the
valueattribute.