How to create a listbox in HTML without allowing multiple selection with HTML?

Spread the love

To create a listbox in HTML without allowing multiple selection with HTML, we use the size attribute.

For instance, we write

<select name="sometext" size="5">
  <option>text1</option>
  <option>text2</option>
  <option>text3</option>
  <option>text4</option>
  <option>text5</option>
</select>

to add a select element with the option elements inside.

We set the size attribute to 5 to render it as a listbox with 5 options displayed at once.

Leave a Reply

Your email address will not be published. Required fields are marked *