HTML <select> size Attribute

❮ HTML <select> tag

Example

<label for="lang">Choose your option:</label>

<select name="language" id="lang" size="2">
  <option value="HTML">HTML</option>
  <option value="CSS">CSS</option>
  <option value="JavaScript">JavaScript</option>
</select>

Meaning

The size attribute sets the number of visible items in the selection list.

When the multiple attribute is not present, only one entry should show; however, when multiple is present, this attribute is useful for setting the size of the scrolling list box.

It Gives the number of options to show to the user. If the multiple attribute is present, then the size attribute’s default value is 4. If the multiple attribute is absent, then the size attribute’s default value is 1.

Note: According to the HTML5 specification, the default value for size should be 1; however, in practice, this has been found to break some web sites, and no other browser currently does that.


Standard Syntax

<select size="number">
  <option>text</option>
</select>



Browser Support




Status







Attribute Values

Value Description
number Specifies non-negative integer
❮ HTML <select> tag