- Instant help with your Html coding problems

Set selected element in a drop down list

Question:
How to set selected element in a drop down list?
Answer:
<!-- Use the selected attribute to select an element / option -->
<select name="range">
  <option value="1">1..9</option>
  <option value="2" selected>10..19</option>
  <option value="3">20..29</option>
</select>    
Description:

Include a selected attribute on an <option> element to make it selected by default when the page first loads.

Share "How to set selected element in a drop down list?"
Tags:
select, drop down, option, html, element
Technical term:
Set selected element in a drop down list