Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML - Change maximum rows on a select tag multiple

So how can I change how many rows a select tag with multiple enabled should be showed:

<select multiple="multiple">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
</select>

This will only show the first four options how can I show the fifth without have to scroll?

like image 676
Mich' Avatar asked Apr 02 '13 16:04

Mich'


People also ask

How do you increase the width of multiple select boxes in HTML?

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). Save this answer.

How do I select multiple items in a drop down list in HTML?

For windows: Hold down the control (ctrl) button to select multiple options. For Mac: Hold down the command button to select multiple options.

How do I limit the size of a drop down list in HTML?

It is not possible to limit the number of visible elements in the select dropdown (if you use it as dropdown box and not as list). But you could use javascript/jQuery to replace this selectbox with something else, which just looks like a dropdown box. Then you can handle the height of dropdown as you want.


3 Answers

Use the size attribute:

<select size="5" multiple name="whatever"> 

References:

  • <select> element.
like image 79
David Thomas Avatar answered Oct 20 '22 04:10

David Thomas


You can use CSS to specify the exact height, but this will probably not render exactly the same across all browsers due to different rendering of the select:

<select multiple="multiple" style="height: 24pt">     <option>1</option>     <option>2</option>     <option>3</option>     <option>4</option>     <option>5</option> </select> 

Fiddle: http://jsfiddle.net/24Myw/

like image 27
darwin Avatar answered Oct 20 '22 04:10

darwin


<select size="any number" name="#" id="#">
    <option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
    <option>5</option>
</select>

it working well

like image 42
Eng Maisa Avatar answered Oct 20 '22 05:10

Eng Maisa