Open In App

What is the use of size Attribute in <select> Tags ?

Last Updated : 23 Feb, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

The size attribute in <select> tag is used to specify the visible number of options displayed in a dropdown list or a list box. This attribute determines the height of the select element by specifying the number of options that are visible at one time without scrolling.

Syntax

<select size="number_of_options">
<!-- Options go here -->
</select>
  • "number_of_options" is the number of options to be displayed without scrolling.
Key Point Description
Visible Options The “size” attribute determines the visible height of the select element by specifying the number of options that are displayed without scrolling.
Default Size If the “size” attribute is omitted, the select element typically displays a single option at a time, allowing users to open the dropdown list to view additional options.
User Interaction Users can interact with the select element to choose an option by clicking on it or using keyboard navigation.

Features

  • Dropdown List Height: The “size” attribute controls the height of the dropdown list, determining how many options are visible at one time without scrolling.
  • Scrolling Behavior: If the number of options exceeds the specified size, a scrollbar is automatically added to the select element, allowing users to scroll through the options vertically.
  • Customization: Developers can adjust the size attribute to fit the design and usability requirements of their web forms, ensuring optimal display and interaction with select elements.

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads