Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set width of a multiple select?

Tags:

html

I want to set default width of multiple select elements :

enter image description here

How to do that ?

like image 332
pheromix Avatar asked Jul 16 '12 12:07

pheromix


4 Answers

Try this,

<select multiple="multiple" style="width: 200px;">

or

<select multiple="multiple" style="width: 10em;">
like image 88
Matt Avatar answered Nov 11 '22 09:11

Matt


The same way as any other element. You write a selector that matches the element (e.g. a select element with a multiple attribute) and then use the width property.

Width applies by default to replaced inline elements (such as selects).

select[multiple] {
    width: 7em;
}
like image 37
Quentin Avatar answered Nov 11 '22 07:11

Quentin


Try This in css

select[multiple=multiple] {width: <default width you want>px ;}
like image 26
Yograj Gupta Avatar answered Nov 11 '22 09:11

Yograj Gupta


Take a look at the max-width property on style.

Ex:

<select name=countries  style="max-width:90%;">
 <option value=af>Afghanistan</option>
 <option value=ax>Åland Islands</option>
 ...
 <option value=gs>South Georgia and the South Sandwich Islands</option>
 ...
</select>  

More information: How to control the width of select tag?

like image 44
Ricardo França Avatar answered Nov 11 '22 08:11

Ricardo França