Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTML | <select> form Attribute

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The <select> tag is an HTML element used to create a drop-down list of options for the user to select the form option.

in this tag with the used  <option>  tags.

<select> tag contains some <option> tags 

Syntax: 

<select>
  <option value="option1">Option 1</option>
  <option value="option2">Option 2</option>
  <option value="option3">Option 3</option>
  <option value="option4">Option 4</option>

</select>

Attribute Values: 

  • value: The value attribute of the <option> tag defines the value that will be sent to the server when the form is submitted, while the text between the opening and closing <option> tags is the display text that the user will see in the drop-down list.

Example: 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>select Form Attribute</title>
    <style>
        h1,
        h2,
        .title {
            text-align: center;
        }
         
        fieldset {
            width: 50%;
            margin-left: 22%;
        }
         
        h1 {
            color: green;
        }
    </style>
</head>
 
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>&lt;select&gt; form Attribute</h2>
      Select your preferred course from the drop-down list:
        <br>
 
        <select form="myGeeks" id="myCourses" autofocus>
            <option value="C++">c++</option>
            <option value="Placement">Placement</option>
            <option value="Java">Java</option>
            <option value="Python">Python</option>
        </select>
        <br>
        <form id="myGeeks">
            <input type="submit">
        </form>
    </center>
</body>
 
</html>


Output:

  

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

  • Google Chrome
  • Edge 12 and above
  • Internet Explorer 
  • Firefox 1 and above
  • Opera
  • Safari

My Personal Notes arrow_drop_up
Last Updated : 03 May, 2023
Like Article
Save Article
Similar Reads
Related Tutorials