PDA

Click to See Complete Forum and Search --> : listbox width


richy
Feb 21st, 2001, 05:10 AM
Does anybody know a way to change the width of a select box in HTML? I've tried the usual like width=6000, but it doesn't make the slightest bit of difference. I know it stretches automatically depending on the size of the longest text, but for looks on the screen I want to make the box wider. Anyone got any ideas?

Jerry Grant
Feb 21st, 2001, 07:46 AM
Setup the width with the syle attribute:

<html>
<head>
<title>How wide do you want it!</title>
</head>
<body>
<table width="100%" height="50%" border="1">
<tbody>
<tr>
<td width="50%">My sizing list</td>
<td>
<select style="width:100%;height=100%" size="5">
<optgroup label="">
<option value="1">1st Item</option>
<option value="2">2nd Item</option>
<option value="3">3rd Item</option>
<option value="4">4th Item</option>
<option value="5">5th Item</option>
<option value="6">6th Item</option>
</optgroup>
</select>
</td>
</tr>
</tbody>
</table>
<p>This will size itself to the size of the table cell</p>
</body>
</html>
:cool:

richy
Feb 21st, 2001, 08:20 AM
thanks very much for that. may i just ask, what does the tbody do?

Jerry Grant
Feb 21st, 2001, 08:44 AM
If you specify attributes in the <TBODY> tag (Font, BGcolor etc.), then they will be used in the body of the table, then revert to the original page formatting after the </TBODY> tag.
This tag was added automatically by XMLspy which I used to build this example. :cool:

richy
Feb 21st, 2001, 09:00 AM
cheers very much for your time.

sail3005
Feb 21st, 2001, 10:45 AM
that listbox width is IE only (what isin't these days)

What browsers is <tbody> supported under? Will it work in NS 4.x?

Jerry Grant
Feb 21st, 2001, 11:06 AM
From MSDN:
This element is available in HTML as of Microsoft® Internet Explorer 3.0, and in script as of Microsoft® Internet Explorer 4.0.

See the HTML 4.0 (http://www.w3.org/TR/REC-html40/) standards

sail3005
Feb 21st, 2001, 12:14 PM
thanks