tomermes
tomermes

Reputation: 23360

limiting select box list length - adding scrollbars

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?

Upvotes: 5

Views: 44448

Answers (3)

Corneliu
Corneliu

Reputation: 2942

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.

Upvotes: 1

devrooms
devrooms

Reputation: 3149

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.

Upvotes: 4

Khez
Khez

Reputation: 10350

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!

Upvotes: 14

Related Questions