Change the number of visible options in a drop-down list:
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".
The size property is supported in all major browsers.
Return the size property:
Set the size property:
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. |
Return Value: | A Number, representing the number of visible options in the drop-down list |
---|
Return the number of visible options in a drop-down list:
The result of x will be:
HTML reference: HTML <select> size attribute