- Trending Categories
- Data Structure
- Operating System
- C Programming
- 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 <select> element?
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 −
<!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>
- How do I set the default value for a column in MySQL?
- How can I select an element by name with jQuery?
- How can I select an element by tag name using jQuery?
- How can I select an element with multiple classes in jQuery?
- How can I consistently remove the default text from an input element with Selenium?
- How can I set the default value of my Tkinter Scale widget slider to 100?
- How can I select an element by its class name using jQuery?
- How can I select an element by its ID attribute using jQuery?
- How can I set an icon for my iOS application?
- How can I set an icon for my Android application?
- How can I show and hide an HTML element using jQuery?
- How to set default value for empty row in MySQL?
- How can I set a Border for an ImageView in Android?
- How can I insert default value in MySQL ENUM data type?
- How do we set the text direction for the content in an element in HTML?