The select tag in HTML is used to create a dropdown list of options which can be selected. The option tag contains the value that would be used when selected.
The default value of the select element can be set by using the ‘selected’ attribute on the required option. This is a boolean attribute.
The option that is having the ‘selected’ attribute will be displayed by default on the dropdown list.
Syntax:
<option value="value" selected>Option Name</option>
Example-1: Using the selected attribute.
<!DOCTYPE html> <html> <head> <title> set the default value for <select> element </title> </head> <body> <h1 style="color: green">GeeksforGeeks</h1> <b> How to set the default value for an HTML <select> element? </b> <p>The Starter option will be selected by default</p> <p>Choose your plan below:</p> <select name="plan" id="plan"> <option value="free">Free</option> <option value="starter" selected>Starter </option> <option value="professional">Professional</option> <option value="corporate">Corporate</option> </select> </body> </html> |
Output:
Before clicking the list:

After clicking the list:

Example-2: This can also be used to add messages like ‘Select an Option’ in the list. This option would have the hidden and disabled attribute in addition to selected.
<!DOCTYPE html> <html> <head> <title> Set the default value for <select> element </title> </head> <body> <h1 style="color: green">GeeksforGeeks</h1> <b>How to set the default value for an HTML <select> element?</b> <p>The Select an Option would be shown by default.</p> <p>Choose your plan below:</p> <select name="plan" id="plan"> <option value="none" selected disabled hidden> Select an Option </option> <option value="free">Free</option> <option value="starter">Starter </option> <option value="professional">Professional</option> <option value="corporate">Corporate</option> </select> </body> </html> |
Output:
Before clicking the list:

After clicking the list:

Recommended Posts:
- How to set a default parameter value for a JavaScript function ?
- How to reset selected value to default using jQuery ?
- How to Assign Default Value for Struct Field in Golang?
- How to hide div element by default and show it on click using JavaScript and Bootstrap ?
- HTML | DOM Track default property
- HTML | default Attribute
- HTML | <track> default Attribute
- How to set textarea scroll bar to bottom as a default using JavaScript/jQuery ?
- How to set default values for Angular 2 component properties?
- C# | Default Constructor
- CSS | :default Selector
- How to replace dropdown-toggle icon with another default icon in Bootstrap ?
- How to add default vertical scaling to a text canvas using Fabric.js ?
- How to add default horizontal scaling to a canvas-type text with JavaScript?
- What is export default in JavaScript ?
- How to create default function parameter in PHP?
- How to remove the default arrow icon from a dropdown list?
- How to close sidebar by default using Bootstrap ?
- How to change an element color based on value of the color picker value using onclick?
- How to change an element color based on value of the color picker value on click?
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.


