HTML | <select> Tag

The <select> tag in HTML is used to create a drop-down list. The <select> tag contains <option> tag to display the available option of drop-down list.

Note: The <select> tag is used in a form to recieve user response.

Syntax:



<select>
    <option>
    <option>
    ...
<select>

Attributes: The attributes of <select> tag are listed below:

  • autofocus: The HTML <select> autofocus Attribute is used to specify that the dropdown should automatically get focus when the page loads. It is a type of boolean attribute.
  • disabled: The <select> disabled attribute is used to specify the select element is disabled. A disabled drop-down list is un-clickable and unusable. It is a boolean attribute.
  • form: The HTML <select> form attribute is used to specify one or more forms that the <select> element belongs to.
  • multiple: The HTML <select> multiple attribute is a Boolean Attribute. It specifies that the user is allowed to select more than one value that presents in <select> element.
  • name: The HTML <select> name attribute is used to specify a name for the drop-down list. It is used to reference the form-data after submitting the form or to reference the element in a JavaScript.
  • required: The HTML <select> required attribute is a Boolean attribute which is used to specify that the user should be selected value before submitting the Form.
  • size: The HTML size attribute is used to specifies the number of visible options in a drop-down list.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML select Tag
    </title>
</head>
  
<body style="text-align:center;">
    <h1>GeeksforGeeks</h1>
      
    <h2>HTML select Tag</h2>
      
    <p>Select one option from drop-down list:</p>
      
    <select>
        <option value="GFG">GFG</option>
        <option value="OS">OS</option>
        <option value="DBMS">DBMS</option>
        <option value="Data Structure">
            Data Structure
        </option>
    </select>
</body>
  
</html>                    

chevron_right


Output:

Supported Browsers: The browser supported by HTML <select> tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : nidhi_biet



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.