Any way to customize the border and background of an HTML <select>
in IE? I can style the border with simple CSS in Firefox, but apparently not in IE.
Asked
Active
Viewed 1.8k times
5

Volker E.
- 5,911
- 11
- 47
- 64

Tony the Pony
- 40,327
- 71
- 187
- 281
2 Answers
9
IE is most likely in quirks mode. Previous versions of IE didn't draw the select
element themselves and thus it couldn't be styled properly (as well as some z-order quirks), so on IE < 8 you simply can't do it, unless you re-implement something like select
in JS. Take a look at the developer tools (F12) to see which browser and document mode IE is in; if it says "Internet Explorer 8" for the Browser mode and not "Quirks mode" for the document mode, you should be ok :)
The following snippet works fine here (IE8β2):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
select {
border: 1px solid red;
}
</style>
</head>
<body>
<form>
<select>
<option>1</option>
<option>2</option>
</select>
</form>
</body>
</html>

Joey
- 344,408
- 85
- 689
- 683
-
Sure, but it's tagged "ie8", so I assumed s?he was talking about IE8. And yes, I've made it rather implicit that previous versions won't do border styling; I'll change that. – Joey Mar 15 '09 at 11:09
-3
Include these tags in your code:
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" />
</head>
This will resolve issues related to Internet Explorer.

Niall C.
- 10,878
- 7
- 69
- 61
-
4Did you read the question or the accepted answer, which was posted over *three years* ago? -1 – Andrew Barber Jun 12 '12 at 22:13
-
1Besides you cannot just include a new where ever you want. You might not think of it as such when you wrote the answer, but that is how it is read. Plus you only set the IE mode to IE 9, which isn't future proof in any way. Especially now that IE 10 is out. IE=edge is more apropiate. Futhermore it is important to understad the old browsers behavior, not just ignore them, by forcing newset version. – Tokimon Mar 14 '13 at 17:28