HTML <select> size attribute

Definition and Usage

size The attribute specifies the number of visible options in the dropdown list.

If size The value of the attribute is greater than 1 but less than the total number of options in the list, the browser will add a scrollbar to indicate that there are more options available to view.

Example

A dropdown list containing three visible options:

<label for="cars">Please select a car brand:</label>
<select name="cars" id="cars" size="3">
  <option value="audi">Audi</option>
  <option value="byd">BYD</option>
  <option value="geely">Geely</option>
  <option value="volvo">Volvo</option>
</select>

Try It Yourself

Syntax

<select size="number">

Attribute Value

Value Description
number

Specifies the number of visible options in the dropdown list. The default value is 1.

If the multiple attribute exists, the default value is 4.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Note:In Chrome and Safari, for size="2" and size="3"This attribute may not work as expected.