×

HTML <select> tag

This tag helps in making the drop-down list on the web page. This is highly used in HTML forms for taking the input from user.

You can use the id attribute for linking the drop-down list to the label.

The options of drop-down list are specified by the <option> tags which are found inside the select element. The <label> tag should always be added for optimum accessibility standards.

Syntax:

<body>
<label for="#">#</label>
<select name="#" id="#">
<option value="#">#</option>
<option value="#"># </option>
<option value="#"># </option>
</select>
</body>

Example

In this example, we make a drop-down list containing multiple options:

<!DOCTYPE html>
<html>
<head>
<title>HTML select tag </title>
</head>
<body>
<label for="countries">pick a country:</label>
<select name="country" id="country">
<option value="India">India</option>
<option value="America">America </option>
<option value="Canada">Canada </option>
<option value="France">France </option>
<option value="Japan">japan</option>
<option value="Nepal">Nepal </option>
</select>
</body>
</html>

Output:

HTML Select Tag

Attributes of Select Tag

1) autofocus

The value determined by this attribute is "autofocus".          This attribute is used to focus the drop-down list on page load.

2) disabled

The value determined by this attribute is "   disabled".          This attribute is used disable the control and hence user cannot interact with the drop-down list.

3) form

The value determined by this attribute is " form-id".  This attribute is used to specify one or more forms, to which select belong to.

4) multiple

The value determined by this attribute is " multiple". This attribute is used to select multiple options from the list.

5) name

The value determined by this attribute is " name" . This attribute is used to determine the name for the drop-down list.

6) required

The value determined by this attribute is "required". This attribute used to select the field before form submittion.

7) size

The value determined by this attribute is " number". This attribute is used to specify the visible number of options in the list.

Now, we are adding one more example so that you can easily understand the concept of select tag.

Example:

In this example, we use the select tag with the optgroup tag:

<!DOCTYPE html>
<html>
<head>
<title>HTML select tag </title>
</head>
<body>
<label for="countries">pick a country:</label>
<select name="country" id="country">
<option value="India">India</option>
<option value="America"> America </option>
<option value="Canada"> Canada </option>
<option value="France"> France </option>
</optgroup>
<optgroup label="Europeancompanies">
<option value="europe">europe</option>
<option value="britian">britian</option>
</optgroup>
</select>
</body>
</html>

Output:

HTML Select Tag

Browser support:

List of browsers that support html <select> tag are mentioned below:

Chrome: Yes

Microsoft Edge: Yes – version 12 needed

Firefox: Yes – version 1 needed

Safari: Yes

Opera: Yes


Related Topics

Html Wbr Tag

The Line Break Opportunity element A word break opportunity is a place in text from where the browser breaks a line. This opportunity is represented by the element wbr in the...

2 minutes read.

Responsive HTML5 and CSS3 Tutorial

Introduction to HTML5 Tutorial HTML5 is the latest and upgraded version of HTML. HTML is a hypertext markup language. Technically, it is not a programming language. It is a markup language. HTML...

17 minutes read.

HTML <address> Tag

Hyper Text Markup Language, HTML is the best markup language for creating Web pages. HTML consists of a wide variety of elements. In all of these elements, one element is...

4 minutes read.

HTML <svg> tag

SVG is used to determine the vector-based graphics in XML format. What is SVG? We utilize SVG tag to specify visuals for the website. The attribute of SVG in a HTML document...

2 minutes read.

HTML Id Attribute

The HTML id attribute represents the unique identifier for an element of the HTML document. Each element has its unique identifier. The id attribute is a global attribute that can be...

12 minutes read.

Caption Tag in HTML

Caption Tag in HTML: The < caption > tag in HTML describes the heading of a table in the HTML text. Browsers typically make the text found above the table...

4 minutes read.

What does HTML stand for?

HTML stands for Hyper Text Markup Language. We use this markup language to design a web page. Web browsers use this language to showcase text, videos, images, audio and other...

6 minutes read.

HTML Elements

An HTML element is nothing but a starting tag and then some content and then the closing tag. So we can say HTML elements is everything from the starting tag...

3 minutes read.

HTML Audio

HTML AUDIO: HTML5 provides a method to embed the audio file into a webpage by using HTML5. Before HTML5 audio files is used to play on the browser with the help of...

1 minute read.

How to create a link with no underline in HTML

In HTML, an anchor tag (<a>) is a Styled Container tag, which means when a hyperlink is created using this, browsers, by default, display the link by applying some styles...

5 minutes read.

HTML <br> tag

HTML is referred to as Hyper Text Markup Language, which is the most popular language for creating Web pages. HTML explains the construction of a Web page. It contains a...

4 minutes read.

HTML5 Attribute

HTML Attribute HTML attributes are special words that provide additional information about the HTML element or attributes.The element or tags have attributes, which define the element's behavior.It also adds attributes with a start...

3 minutes read.

HTML Nested Table

HTML nested table refers to a table that is created inside another table. The table is in the form of rows and columns. From left to right are called horizontal rows,...

5 minutes read.

HTML <strong> tag

The strong element in HTML is used to display the real significant information in bold so that the user or reader will understand it easily. Syntax: <p> <strong>………… </strong> </p> Example Here, we will demonstrate how to...

2 minutes read.

HTML Attributes

HTML Attributes provide the additional information about HTML elements. Attributes are always specified in the start tag. Attributes usually comes in pairs. lang Attribute This attribute helps in declaring the language...

2 minutes read.

HTML SVG

HTML SVG: SVG stands for Scalable Vector Graphics which defines the graphics for the web. It is a language for describing 2-D graphics in XML. Each drawn shape in SVG is...

1 minute read.

HTML <strike> tag

The HTML <strike> tag is used to specifies strikethrough text. The tag is deprecated now and <del> tag is used in HTML files instead of it. All the global and...

2 minutes read.

HTML Code

Before jumping into the topic, let’s understand a common scenario where we have a code snippet in our HTML file. By code snippet, we mean computer code, which is written...

5 minutes read.

HTML <script> Tag

For embedding a client -side script, we use script tag in html tag. This <script> tag can be used for containing scripting statements. It can also point another external script file...

2 minutes read.

HTML Headings

The titles and subtitles of our webpages are known as HTML headings. Let’s not talk about webpages but giving heading to almost everything like normal paragraphs, articles or let it...

2 minutes read.