When i use an html select box which has about 50 items, I get a very long list that fully appears. I would like to use scrollbars instead. how do I do that?
Asked
Active
Viewed 4.2k times
3 Answers
14
You need to use CSS, specifically height and overflow:
CSS
.select{
height:100px;
overflow:scroll;
}
HTML
<select class="select"></select>
If you need anything more specific, ask!

Khez
- 10,172
- 2
- 31
- 51
-
Oh, actually, yes - I thought tomer was after a dropdown sleect box :O – devrooms Apr 08 '11 at 09:31
-
I'm confused now... He wanted to limit the number of elements on the dropdown ? – Khez Apr 08 '11 at 09:33
4
It is not possible to do this in HTML. See Height of an HTML select box (dropdown)
There are other ways of achiving this though javascript or jQuery, with links on that page to some jQuery plugins which create a "fake" html select box that looks and behaves like one, but can have the height set.
1
It is not possible to set the number of visible items for a single value select box. There is a size attribute, but that will transform the dropdown into multiple selection list.

Corneliu
- 2,932
- 1
- 19
- 22