Rey Libutan
Rey Libutan

Reputation: 5314

How to remove whitespace of empty <select> in IE

Below are screenshots I took on an empty <select> in IE8 and Chrome. What happens is that when a <select> element is empty, IE8 still shows a long dropdown but with just whitespaces while Chrome shows nothing (which is what I want too in IE).

Any ideas for this?

P.S. I can't add dummy <option> for this.

empty select in IE and other browsers

Upvotes: 3

Views: 1023

Answers (1)

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

You could do it by inserting a empty option or optgroup like this

<select><optgroup></optgroup></select>

or

<select><option></option></select>

or as @Shivam you could do this as this

<select><option selected="selected">Pick an Option</option>

But you mentioned you don't need dummy option. But the browser behaves you mentioned in your question by default.

Upvotes: 2

Related Questions