What values can appear in the "selected" attribute of the "option" tag?
html, html-select
Solution
Different browser may treat this attribute differently. According to the MSDN documentation (for Internet Explorer):
To select an item in HTML, it is not necessary to set the value of the SELECTED attribute to true. The mere presence of the SELECTED attribute set its value to true.
In firefox and Safari this does work:
<option selected='false' />
From what I can tell by looking at the official WC3 standard for HTML4, the supported case is only:
<option selected='selected' />
You will either need to selectively emit the attribute, or use javascript to control which item is initially selected.
Problem
I have some markup similar to the following: ``` <select> <option selected="selected">Apple</option> <option selected="">Orange</option> </select> ``` In this case, "Orange" shows as the selected item. I would have expected making the `selected` attribute blank would undo its effects. Is there a way to write this without simply leaving the attribute out?