×

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.

HTML Font Size

The HTML <font> tag uses the size attribute to specify the size of the text. We can set the size attribute’s value from 1 to 7. The default size of...

4 minutes read.

Html &lt;datalist >Tag

The autocomplete feature in HTML files is provided by the <datalist> tag. It can be used in conjunction with an input tag to enable users to quickly fill out form...

4 minutes read.

HTML <summary> tag

When we simply want to show the primary heading or topic name of hidden detailed material to users, then we can achieved this by using the summary tag. This makes it...

2 minutes read.

HTML Ordered List

We use <ol> tag to make an ordered list in html. An ordered list is made to make a list of items in ordered form, ordered list can be either...

3 minutes read.

HTML Video

HTML VIDEO: HTML5 has introduced the <video> tag to embed video into the webpage directly without using the plug-ins.   Syntax: <video attributes >     <source src="address" type="video/mp4">     Your browser does not support the video tag.   </video> <video width="320" height="240" controls>     <source src="mountain.mp4" type="video/mp4">     Your browser does not support the video tag.   </video> Output: ← Prev ...

1 minute read.

How to insert image in HTML

An image (technically digital image) in HTML or even in general technical aspects is a binary representation of visual information. By visual information we mean, in the form of drawings/pictures,...

5 minutes read.

How to add Google Translate Button on your Webpage?

Google translator is a multi-language translator used for translating the webpage. Google develops it. In today's digital age, it is essential because information is available worldwide in some specific language...

5 minutes read.

HTML <sub> tag

The sub element in HTML is used to describe one or more subscript texts. If The sub tag shows the text which is presented in a smaller font and below...

2 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 Unordered List

In HTML, we have <ul> tag which defines the unordered list. And it is also known as bulleted list, because as we know it is not ordered list therefore it...

2 minutes read.

HTML Font Color

The HTML <font> tag has an attribute called color, which defines the color of the text. We use the color attribute inside the <font> tag to specify the color of...

6 minutes 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.

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 <style> tag

The section of information that we want to style is contained in html style tag. It includes CSS, which is used to design the text and images in the web page. Syntax: <head> <title>…………....

3 minutes read.

HTML Text Format

Introduction HTML may format text in two different ways. The HTML tags define a text property to make it appear one way or another. A text element may also be formatted...

7 minutes read.

HTML Event Attributes

HTML Event Attributes If a browser responds to the user behavior, an event is called. For example, if we click on the submit button, a box of details will appear on...

4 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.

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.

How to append HTML code to a div using JavaScript?

In HTML, we have a div tag which is used to create a box where we can put a lot of other tags. So it works like a container. So,...

4 minutes read.