- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I set the default value for an HTML
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.
Example
You can try to run the following code to learn how to set the default value for HTML <select> element −
<!DOCTYPE html> <html> <head> <title>HTML Select Element</title> </head> <body> <p> Select any one:</p> <form> <select name = "dropdown"> <option value = "Java">Java</option> <option value = "Discrete Mathematics" selected >Discrete Mathematics</option> <option value = "Chemistry">Chemistry</option> </select> </form> </body> </html>
Advertisements