The OPTION element has a "label" attribute which, when present, is supposed to be used in the user interface rather than the text contents of the element. This is described on <http://www.w3.org/TR/REC-html40/interact/forms.html>: 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. WebKit ignores this attribute, though a getter and setter are supplied in the Objective-C DOM API at least. IE supports this attribute, though Firefox ignores it. Here's an example. This should show a pop-up menu with menu items titled "1" and "2", but instead it shows a pop-up menu with long menu item titles: <select> <option value="1" label="1">the label for this element is "1"</option> <option value="2" label="2">the label for this element is "2"</option> </select>
Created attachment 6487 [details] test cases that include empty label
Created attachment 6488 [details] patch to support label attribute for OPTION elements
Comment on attachment 6488 [details] patch to support label attribute for OPTION elements Oops, I didn't mean to mark it review-+. Also, I haven't attached the layout tests yet, so I'll set this to review- until I have the tests ready.
Created attachment 6489 [details] layout tests for patch
Comment on attachment 6488 [details] patch to support label attribute for OPTION elements Now that I've attached the new layout tests, this is ready for review.
HTML also will let you write: <option label>Foo</option> Should make sure we match WinIE in that situation too.
Also, what about list boxes? Need to see if label is used for <select size="10"> for example.
Also need to test optgroups.
In response to comment 6: the behavior for this case is the same on MacIE as in WebKit; I'll add a layout test. In response to comment 7: list boxes don't use the label but should; I'll write a bug In response to comment 8: optgroups already deal with the label (used as hierarchical menu item title)
I was wrong about list boxes in my previous comment; they do work correctly now with label attributes. (I was using the wrong Safari when I tested that case.) I'm adding another layout test for this.