Is it possible to change the border color on a <select> element in an HTML form?
The border-color style works in Firefox but not IE.
I could find no real answers on Google.
Is it possible to change the border color on a <select> element in an HTML form?
The border-color style works in Firefox but not IE.
I could find no real answers on Google.
No, the <select>
control is a system-level control, not a client-level control in IE. A few versions back it didn't even play nicely-with z-index, putting itself on top of virtually everything.
To do anything fancy you'll have to emulate the functionality using CSS and your own elements.
As Diodeus stated, IE doesn't allow anything but the default border for <select>
elements. However, I know of two hacks to achieve a similar effect :
Use a DIV that is placed absolutely at the same position as the dropdown and set it's borders. It will appear that the dropdown has a border.
Use a Javascript solution, for instance, the one provided here.
It may however prove to be too much effort, so you should evaluate if you really require the border.
In IE it just isn't going to happen. A reasonable alternative is to create a control that functions like a tag using jQuery. Here's one that does just that and is compatible with FF/IE6/IE7.
I would consinder enclosing that select block within a div block and setting the border property like so:
<div style="border: 2px solid blue;">
<select style="width: 100%;">
<option value="Sal">Sal</option>
<option value="Awesome">Awesome!</option>
</select>
</div>
You should be able to play with that to accomplish what you need.
<del>You can set the border color in IE however there are some issues.</del>
Argh... I could have sworn you could do this... just tested and realized I wasn't correct. The notes below still apply though.
1.) in IE8 (Beta1 -> RC1) changing the border color or the background color/image causes a de-theming of the control in WindowsXP (the drop arrow and box look like Windows 95)
2.) you still can't style the options within the select control very well because IE doesn't support it. (see bug #291)