Click to See Complete Forum and Search --> : How do i set the 'length' of a select box?


mongous
12-20-2002, 12:24 PM
This is a dumb question but..

How do i set the 'width' of a select box?

The 'size' attribute only controls how many lines are displayed, but I can't for the life of me figure out how to alter the 'width'.

Thanks.

swon
12-20-2002, 12:38 PM
Try this code:

<select name="name" style="width:100px">

better is it to make an css class(cause NS4 hates the style attribute)

mongous
12-20-2002, 02:41 PM
Thx!

Stefan
12-20-2002, 07:40 PM
Originally posted by swon
<select name="name" style="width:100px">


That is actually incorrect code and only a buggy browser will make the selectbox 100px wide.

CSS width and height doesn't apply to (non replaced) inline elements, to which basicly all form elements belong.

To make it work you have to make the element into blocklevel also.

Ie

<select name="name" style="width:100px; display:block;">

swon
12-20-2002, 08:38 PM
It works for most of browser >4 so are the most buggy browsers?

Stefan
12-20-2002, 09:12 PM
Originally posted by swon
It works for most of browser >4 so are the most buggy browsers?

Sorry, ignore me.

<select> happens to be a replaced inline element, and thus width do apply.
:rolleyes:
Time for me to sleep I guess.