44

I used the CSS below to hide the drop down arrow in FF, safari, chrome and added my own image to customize.

select 
{
  -webkit-appearance:none;
  -moz-appearance:none;
  -o-appearance:none;
   appearance:none; 
}

For IE10, I used the pseudo-element

select::-ms-expand{
  display:none;
}

I don't know how to apply the same for IE9 & IE8. Can anyone tell me how to hide the drop down arrow in IE8 & IE9.

ecnepsnai
  • 1,882
  • 4
  • 28
  • 56
Royal
  • 752
  • 2
  • 14
  • 29
  • 2
    You will definitely have major difficulty with this in IE8. Because of the way IE8 and earlier renders select boxes, it is virtually impossible to do any customised styling on them at all, unless you go all the way to writing your own entire select box widget in javascript. IE9 might be tricky, but it should be possible, unlike with IE8. – Spudley Oct 16 '13 at 15:25
  • @Spudley no problem can you answer me how to do it in ie9. – Royal Oct 16 '13 at 15:29
  • it's still not going to be easy, but worst case in IE9 you can simply stick an element on top of the arrow to hide it. You could use a `::before` selector to do this maybe. in IE8 and earlier, that isn't possible because select boxes will always be rendered on top of other content. – Spudley Oct 16 '13 at 15:35
  • some ideas for IE9 at [Select removing dropdown arrow](http://stackoverflow.com/questions/16603979/select-removing-dropdown-arrow) – andyb Oct 16 '13 at 15:36
  • 1
    BTW, your code does not remove any arrow in my Firefox/24 for Windows 7 {[fiddle](http://jsbin.com/ehEvayu/1/edit)}... Looks like an [known issue](https://bugzilla.mozilla.org/show_bug.cgi?id=649849). – Álvaro González Oct 16 '13 at 15:39
  • @ÁlvaroG.Vicario Not testing in FF/Windows 7 but working in fedora/FF 24 – Royal Oct 16 '13 at 15:44
  • @Royal - see my answer for the closest you'll get to an IE9 solution. – Spudley Oct 16 '13 at 16:00
  • Possible duplicate of [Remove Select arrow on IE](http://stackoverflow.com/questions/20163079/remove-select-arrow-on-ie) – Muath Mar 06 '16 at 09:14

5 Answers5

40

You've asked for a solution for IE8 and IE9.

Let's start with IE8. Short answer: It's not possible. Because of the way IE8 and earlier render select boxes, you simply cannot hide the drop-down arrow. Select box controls are impossible to style in old IE, and always appear positioned above any other content.

There simply isn't any solution to this, other than rewriting the entire select box control in Javascript.

Now IE9. You can hide the drop-arrow. It's not a standard thing, but you can hack it.

You need to start with a wrapper element (eg a <div>) around your select box. You can then style this with a :before selector to place an extra bit of content over the top of the drop-arrow, effectively hiding it.

Here's the CSS:

div {
    position:relative;
    display:inline-block;
    z-index:0
}
div select {
    z-index:1;
}

div:before {
    display:block;
    position:absolute;
    content:'';
    right:0px;
    top:0px;
    height:1em;
    width:1em;
    margin:2px;
    background:red;
    z-index:5;
}

...and see here for the jsFiddle to see it in action.

Note, I've used red as the overlay colour to make it obvious what's happening. Clearly in normal use you'd want to use white so it doesn't stand out.

You'll also note that as I stated above, this does not work in IE8.

Obviously, this isn't the same as the "proper" solution for IE10 and other browsers, which actually remove the arrow; all we're doing here is hiding it. And this means that we end up with an annoying white patch at the end of the select box where the arrow used to be.

We can do further styling to solve this: eg if we make the container element a fixed width and with overflow:hidden, we can get rid of the white patch, but then we have issues with the borders of our select box being broken, so we have to do further styling fixes; it can all get a bit messy. Plus of course, this option only works if the select box itself is a known fixed width.

So there you have it: There are options for doing this in IE9. They're not pretty though, and frankly may not be worth the effort. But if you're desperate, you can do it.

Oh, and don't forget to make this CSS code specific so it only runs on IE9, otherwise it will cause issues on other browsers.

Spudley
  • 166,037
  • 39
  • 233
  • 307
  • 4
    This is a great solution for a visual fix to the issue. The one noticeable side effect, however, is that the user cannot click on the cover element to activate and open the select drop down. Take this into consideration if using this approach. – Neil Monroe Feb 06 '15 at 16:37
  • 3
    Ya this is an interesting fix, definitely makes it look nice, still makes me rage a bit because IE9 is a dumpster fire – labago Mar 04 '15 at 22:21
  • This is a little less than perfect on modern browsers that offer a CSS solution. For 2017, I would say it is ok for IE8 to not be supported by almost any site, and it is ok for visual polishes to be disabled for IE9 as long as the site is functional. – Adam Leggett Feb 24 '17 at 20:37
  • @AdamLeggett - yeah, you're absolutely right. I certainly don't support IE8 or IE9 today. The answer was given in 2013 though, when things were a bit different. – Spudley Feb 25 '17 at 15:59
  • @Spudley, I find it's usually not very hard to support IE9 with degraded appearance but full functionality. Otherwise, agreed. – Adam Leggett Feb 27 '17 at 18:14
20

You cannot remove the arrow in pure CSS for IE9 < That's why they made ::-ms-expand for IE10.

You could, however, do something like this. jsFiddle here

In this example, you set a fixed width on select, and wrap a div with a lower width and overflow:hidden in order to mask/hide the dropdown. It has full support. This essentially does hide the arrow in all browsers.

CSS

div {
    width: 80px;
    overflow: hidden;
    border: 1px solid black;
}
select {
    width: 100px;
    border: 0px;
}
Josh Crozier
  • 233,099
  • 56
  • 391
  • 304
  • Your answer is working fine in fiddle but while implementing it in my application,i am not able to set width for "select".Padding in negative value also not apply in IE9.Any idea to solve this. – Royal Oct 17 '13 at 16:30
  • I have a doubt,in fidde i am able to increase the width of "select" where as in my application i tried the same it is not working. – Royal Oct 18 '13 at 06:46
  • @Royal That's weird. Can you provide an example or something? I'll take a look at it. – Josh Crozier Oct 18 '13 at 16:23
2

The only way to accomplish this in older versions of IE is to wrap the <select> in a slightly smaller container and set overflow: hidden; This would hide the arrow on the right side but still allow you to open the drop-down by clicking on it. It's messy but it's the only way to accomplish what you want.

In the past these elements have not been styleable because they were considered part of the operating system. It appears that this is becoming less of an issue now that the pseudo-elements like you mentioned are available.

nullability
  • 10,545
  • 3
  • 45
  • 63
2

not sure about every use case, but in my case with a fixed width x height bg pic set up for the parent, this worked for IE and FF too:

HTML

<div id="parent">
  <select>
    ...
  </select>
</div>

CSS

#parent{
  ...
  overflow: hidden;
  width:100px; // for example
}

#parent select{
  ...
  width:120px;
}

jsfiddle

tmatyo
  • 412
  • 5
  • 8
1

Another bad but functionally solucion for IE9 :D

Preview

// CSS

div {
    position:relative;
    display:inline-block;
    border:solid black 1px;
    z-index:0
}
div select {
    z-index:1;
    border:none;
    width:200px;
}

div:before {
    display:block;
    position:absolute;
    content:url('http://help.eclipse.org/mars/topic/org.eclipse.stardust.docs.enduser/html/handbooks/execution-clients/rules/images/arrow.png');
    right:-2px;
    top:-1px;
    padding-left:2px;
    height:18px;
    width:15px;
    margin:2px;
    background:white;
    z-index:445;
    border: 0;
}

All you need is encapsulate this code with this IE9 media query hack

/* IE9 */
    @media screen and (min-width:0\0) {

    }
/* IE9 */

jsFiddle

Alberto
  • 11
  • 3