I want to be able to define a height for the select element when its multiple to false
select{height: 30px;}
But I don’t want it to be applied when the select has the multiple=yes.
Can it be defined in CSS?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
First things first, in order for a
selectelement to not be in multi-selection mode, themultipleattribute must be entirely omitted. Even if you setmultiple="no"ormultiple="false", the standard behavior is the same as HTMLmultipleor XHTMLmultiple="multiple". For more information, refer to the HTML spec.With this in mind, use the CSS3
:not()selector to exclude anyselectwith that attribute:Or if you need IE7+ support, apply the height to all
selectelements then reset it for those with that attribute: