Scripsit Kim André Akerĝ:
You could use styles, like this:
<select style="width: 200px">
or:
<option style="width: 200px">
But what you _should_ do (assuming it's a good idea to set the width in the
first place - it seldom is) is to place a style sheet rule like
select { width: 15em; }
into your CSS file.
Both will work syntactically, but the former is guaranteed to produce
the desired effect in all CSS-conforming browsers.
No, you cannot guarantee such things. CSS is just optional presentational
suggestions, both in theory and in practice. (Besides, an <optionelement
is by default an inline element, so a conforming browser will ignore a width
setting it even for formal reasons.)
You can also put this in your stylesheet instead of cluttering up the
markup with individual styles (especially if there are more than one
element that needs this width).
Well, yes.
But you should also consider _why_ you want to set the width of <select>.
It's almost always based on a wrong analysis and will create problems rather
than solve them.
P.S. Style sheet issues belong to c.i.w.a.stylesheets. There is no way to
set the width of a select or option element in HTML, except in the sense
that the width is affected by the content length of the longest option. Old
versions of Netscape recognized a width="..." attribute in <select>, but
even modern descendants of Netscape, like Firefox, don't support it any
more.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/