Signup/Sign In
PUBLISHED ON: FEBRUARY 20, 2021

HTML Select Tag

In HTML, the <select> tag is used to create a drop-down list.

  • The <select> tag is an inline element.

  • The <option> tag is used inside the <select> tag is used to define the options that should be available in the list.

HTML <select> Tag Syntax and Usage

The <select> tag requires the start(opening) tag and end(closing) tag. Given below is its basic syntax:

<select>
...content here
</select>

HTML <select> Tag Attributes

HTML5 <select> tag supports both global and event attributes and some of the common attributes are given below:

1. Size

This attribute is used to represent the number of rows that should be visible in a list one at a time. By default, the size attribute has value 0.

2. Required

It is a boolean attribute that indicates that an option having a non-empty value must be selected.

3. Name

This attribute is used to specify the name of the control.

4. Autofocus

The autofocus attribute is used to specify that a form control should focus on the input whenever the page loads; it is also a boolean attribute.

5. Form

This attribute is used to specify the form to which this drop-down list belongs to.

6. Multiple

This attribute is used to select multiple options at a time.

7. Disabled

It is a boolean attribute; it is used to specify that the user cannot interact with a control.

HTML <select> Tag Basic Example

Below we have a basic example to show the usage of the <select> tag:

Default CSS Settings for HTML <select> tag

None.

Browser Support for HTML <select> tag

Following browsers support this attribute:

  • Firefox 1+

  • Google Chrome 1+

  • Internet Explorer 2+

  • Apple Safari 1+

  • Opera 4+



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.