Select size Property
Example
Change the number of visible options in a drop-down list:
document.getElementById("mySelect").size = "4";
Try it Yourself »
Definition and Usage
The size property sets or returns the value of the size attribute of a drop-down list.
The size attribute specifies the number of visible options in a drop-down list.
Note: In Chrome and Safari, the size attribute may not work as expected for size="2" and size="3".
Browser Support
Property | |||||
---|---|---|---|---|---|
size | Yes | Yes | Yes | Yes | Yes |
Syntax
Return the size property:
selectObject.size
Set the size property:
selectObject.size = number
Property Values
Value | Description |
---|---|
number | Specifies the number of visible options in a drop-down list. If the value is greater than 1, but lower than the total number of options in the list, the browser will add a scroll bar to indicate that there are more options to view. |
Technical Details
Return Value: | A Number, representing the number of visible options in the drop-down list |
---|
More Examples
Example
Return the number of visible options in a drop-down list:
var x = document.getElementById("mySelect").size;
Try it Yourself »
Related Pages
HTML reference: HTML <select> size attribute
❮ Select Object