Java, J2EE & SOA Certification Training
- 37k Enrolled Learners
- Live Class
Select and Action are one of the most important tags in HTML and one cannot create a DropDown Menu and not use it. Let’s start our journey of select and option tag in HTML in the following manner:
The <select> tag is used within a form for defining a select list in HTML. Which appears when clicking on the form element and it proceeds the user to select one of the options.
<!DOCTYPE html> <html> <head> <title>HTML select tag </title> </head> <body> <form action="/cgi-bin/dropdown.cgi" method="post"> <select name="dropdown"> <option value="html" selected>html</option> <option value="css" selected>css</option> <option value="php" selected>php</option> </select> <input type="submit" value="submit" /> </form> </body> </html>
<option value="css" selected>css</option>
|Name||It is used to give a name to the control that is sent to the server to be recognized and get the value.|
|Size||It is used to present a scrolling list box.|
|Multiple||If it is set to “multiple” then allows the user to select the multiple items from the menu.|
<!DOCTYPE html> <html> <head> <title>HTML option tag </title> </head> <body> <form action="/cgi-bin/dropdown.cgi" method="post"> <select name="dropdown"> <option value="physicsl" selected>physicsl</option> <option value=”chemistry”selected>chemistry</option> <option value="maths" selected>maths</option> </select> <input type="submit" value="submit" /> </form> </body> </html>
List of Attributes of Option Tag
|Value||This value will be used if an option in the select box is selected.|
|Selected||Specifies this option should be firstly selected value when the page loads.|
|Lable||It is an alternative way of labeling options.|
With this, we come to an end of this Select and Option Tag in HTML article. I hope you understood the importance of Select and Option tag in HTML.
Check out our Full Stack Web Developer Masters Program which comes with instructor-led live training and real-life project experience. This training makes you proficient in skills to work with back-end and front-end web technologies. It includes training on Web Development, jQuery, Angular, NodeJS, ExpressJS, and MongoDB.
Got a question for us? Please mention it in the comments section of “Select & Option Tag in HTML” blog and we will get back to you.