How can I set the default value for an HTML <select> element?

JavascriptWeb DevelopmentFront End Scripts

With HTML, you can easily create a simple drop down list of items to get user input in HTML forms. Use the <select> element for this, which is a select box, also called drop down box, with option to list down items.

Also, you can set the default value from the dropdown list of items in HTML forms. For that, add selected in the <option> tag for the value you want to preselect.


You can try to run the following code to learn how to set the default value for HTML <select> element −

Live Demo

<!DOCTYPE html>
      <title>HTML Select Element</title>
      <p> Select any one:</p>
         <select name = "dropdown">
            <option value = "Java">Java</option>
            <option value = "Discrete Mathematics" selected >Discrete Mathematics</option>
            <option value = "Chemistry">Chemistry</option>
Updated on 18-Jun-2020 06:02:56