user591790
user591790

Reputation: 555

how to give width of ListBox in HTML5

I want to give ListBox width in HTML5. Please give me some idea.

Upvotes: 0

Views: 6703

Answers (3)

dotnetN00b
dotnetN00b

Reputation: 5131

CSS

#example {
    width: 300px;
}

HTML

<select size="4" id="example" name="example">
<option selected>Fries</option>
<option>Drink</option>
<option>Pie</option>
<option>Salad</option>
<option>Shake</option>
</select>

For completeness and to show an actual HTML5 Listbox (no JS needed).

Upvotes: 0

Zoltan Toth
Zoltan Toth

Reputation: 47687

You can style it as a regular input - all CSS properties applicable to it

DEMO


CSS

input[list] {
    width: 300px;
}

HTML

<input type="text" list="browsers" />
<datalist id="browsers">    
    <option> Chrome </option>   
    <option> Firefox </option>
    <option> IE9 </option>
</datalist>

Upvotes: 1

Aghilas Yakoub
Aghilas Yakoub

Reputation: 29000

You can try with

style="width:150px;"

Upvotes: 0

Related Questions