5

I want to set default width of multiple select elements :

enter image description here

How to do that ?

Community
  • 1
  • 1
pheromix
  • 18,213
  • 29
  • 88
  • 158

5 Answers5

14

Try this,

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

or

<select multiple="multiple" style="width: 10em;">
Matt
  • 1,953
  • 1
  • 19
  • 42
3

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;
}
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
1

Try This in css

select[multiple=multiple] {width: <default width you want>px ;}
Yograj Gupta
  • 9,811
  • 3
  • 29
  • 48
1

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?

Community
  • 1
  • 1
Ricardo França
  • 2,923
  • 2
  • 18
  • 18
1

You can use "size" attribute like below:

<!DOCTYPE html>
<html>
<body>

<select size="3">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

</body>
</html>
Burak Ibis
  • 443
  • 4
  • 13