HTML select Tag size Attribute Tutorial

In this section, we will learn what the size attribute is and how to use it.

What is size Attribute in HTML <select> Tag?

The size attribute in an HTML <select> element declares the number of visible items on that list.

By default, the number of visible items on a list is just one. That means you can see one item on the list (before selecting that dropdown list)

But with help of the size attribute, we can change the number of visible items.

For example, let’s say the value of the size attribute is set to 3. This means the visible items of the target dropdown list are 3 items at a time.

HTML size Attribute in <select> Tag Syntax:

<select size = “number”> </select>

<select> Tag size Attribute Values

The value we set for the size attribute is a digital number declaring how many items should be visible to users at a time.

Example: using size attribute in HTML <select> tag

See the Pen using size attribute in HTML <select> tag by Omid Dehghan (@odehghan) on CodePen.

Leave a Reply