THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Select size Property

Select Object Reference Select Object

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

Internet Explorer Firefox Opera Google Chrome Safari

The size property is supported in all major browsers.


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;

The result of x will be:

5
Try it yourself »

Related Pages

HTML reference: HTML <select> size attribute


Select Object Reference Select Object