- 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
HTML
The size attribute of the <select> element is used to set the number of visible list items from a drop-down list. A scrollbar would get added if the size is set more than 1.
Following is the syntax−
<select size="num">
Above, num is the count of the visible list items in the drop-down list.
Let us now see an example to implement the size attribute of the <select> element−
Example
<!DOCTYPE html> <html> <body> <h1>Candidate Profile</h1> <p>Following are the details to be submitted by the candidate:</p> <h2>Educational Qualification</h2> <form action=""> <section> <h3>Graduation</h3> <select size = "2"> <option value="bca">BCA</option> <option value="bcom">B.COM</option> <option value="btech">B.TECH</option> <option value="btech">B.SC</option> </select> </section> <section> <h3>Postgraduation</h3> <select size="2"> <option value="mca">MCA</option> <option value="mcom">M.COM</option> <option value="mtech">M.TECH</option> <option value="msc">M.Sc</option> </select> </section><br> <input type="submit" value="Next"> </form> </body> </html>
Output
In the above example, we have set two drop-down lists−
<section> <h3>Graduation</h3> <select size = "2"> <option value="bca">BCA</option> <option value="bcom">B.COM</option> <option value="btech">B.TECH</option> <option value="btech">B.SC</option> </select> </section> <section> <h3>Postgraduation</h3> <select size="2"> <option value="mca">MCA</option> <option value="mcom">M.COM</option> <option value="mtech">M.TECH</option> <option value="msc">M.Sc</option> </select> </section>
We have set two drop-down lists above with the size attribute that allows to set the number of visible list items−
<select size="2">
Advertisements