Make multiple-select to adjust its height to fit options without scroll bar

Alex picture Alex · Mar 30, 2012 · Viewed 167.6k times · Source

Apparently this doesn't work:

   select[multiple]{
     height: 100%;
   }

it makes the select have 100% page height...

auto doesn't work either, I still get the vertical scrollbar.

Any other ideas?

enter image description here

Answer

Alex picture Alex · Sep 25, 2012

I guess you can use the size attribute. It works in all recent browsers.

<select name="courses" multiple="multiple" size="30" style="height: 100%;">