[ic] Keeping the "selected" tag up

Mike Heins mike at perusion.com
Wed Oct 22 22:47:20 EDT 2003

Quoting Grant (listbox at email.com):
> The selected tag seems to be designed to be used to output HTML like this:
> <option SELECTED value="1">1
> but the proper method is specified here:
> http://www.w3schools.com/tags/tag_option.asp as:
> <option selected="selected" value="1">1

They can say it is the proper way, but the HTML spec differs. It is an
attribute that has an implicit value, and you need not add ="selected".

HTML 4.0 spec 17.6:

 In this example, we create a menu that allows the user to select which
   of seven software components to install. The first and second
   components are pre-selected but may be deselected by the user. The
   remaining components are not pre-selected. The size attribute states
   that the menu should only have 4 rows even though the user may select
   from among 7 options. The other options should be made available
   through a scrolling mechanism.

   The SELECT is followed by submit and reset buttons.
<FORM action="http://somesite.com/prog/component-select" method="post">
   <SELECT multiple size="4" name="component-select">
      <OPTION selected value="Component_1_a">Component_1</OPTION>
      <OPTION selected value="Component_1_b">Component_2</OPTION>
   <INPUT type="submit" value="Send"><INPUT type="reset">

Note they, in their authoritative example, do not use it in the
way you say is proper. In fact, they recommend you don't do it
that way.

  B.3.4 Boolean attributes

   Authors should be aware that many user agents only recognize the
   minimized form of boolean attributes and not the full form.

   For instance, authors may want to specify:
<OPTION selected>

   instead of
<OPTION selected="selected">

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike at perusion.com>

Being against torture ought to be sort of a bipartisan thing.
-- Karl Lehenbauer

More information about the interchange-users mailing list