How to preselect a value in a dropdown list of items in HTML forms?

HTMLWeb DevelopmentFront End Technology

With HTML, you can easily create a simple drop down list of items to get user input in HTML forms. A select box also called drop down box provides an option to list down various options in the form of drop down list.

You can also preselect a value in 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 preselect value in a dropdown list of items works in HTML form −

Live Demo

<!DOCTYPE html>
      <title>Select Box Control</title>
      <p> Select any one:</p>
         <select name = "dropdown">
            <option value = "Java" selected>Java</option>
            <option value = "Discrete Mathematics">Discrete Mathematics</option>
Published on 07-Feb-2018 08:13:19