Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drop down list width

Status
Not open for further replies.

mrtopher

Programmer
Aug 27, 2003
34
US
Does anyone know of a way to make drop down lists a certain width so you have uniform looking forms?

I have tried setting width values through CSS but it doesn’t seem to work.
 
If you can't get CSS width to work, you could work from the fact that select box will always expand to accomodate the longest option. Knowing that, you could begin each select box with a uniform option that is longer than any other on the page and is there just to provide an opening:
Code:
<select>
 <option>------ Select option ------</option>
 <option value="1">Option 1</option>
 <option value="2">Option 2</option>
 <option value="3">Option 3</option>
 <option value="4">Option 4</option>
 <option value="5">Option 5</option>
</select>
And so on. This is possibly the best way, since you said CSS is not working for you.
 
css works for me in IE6 and firefox on WinXP:

Code:
<select style="width:100px;">
<option>a</option>
</select>
<br />
<select style="width:150px;">
<option>a</option>
</select>

=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); } finally { rtfm(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top