1

I'm experience an issue with centering select option elements in IE8. Basically, this works for me in other browsers, but not in IE8.

Up to now I've managed to avoid any browser-specific hacks, but from the research I've done, it seems like this may not be possible with IE8.

Here's sample code to illustrate the problem.

<html>
<head><style>select { text-align: center; }</style></head>
<body>Debugging Centering Issue
    <select>
        <option>Short option</option>
        <option>Very Long Option with lots of horizontal width</option>
    </select>
    </body>
</html>

Load it up in FF and the combobox is centered. Do the same in IE and it's left-aligned.

I've tried using the jQuery Center Element Plugin, without any success.

Is there a way to do this?

Just to clarify, I'm talking about centering the options (drop-down items) on the select element, not the select element itself.

Peter Bernier
  • 8,038
  • 6
  • 38
  • 53

1 Answers1

0

Not possible by default.

Check: how to make sure select option text align in the center in IE?

If it really should be centered I would create a custom select with javascript.

I can code you an example with HTML and Jquery if you like.

Community
  • 1
  • 1
PeeHaa
  • 71,436
  • 58
  • 190
  • 262
  • I'd seen the thread you linked to, it didn't really have any answer other than 'it doesn't work' which is why I created my question with clear sample code. I would think there's got to be a way to do this without hacking together a jquery combobox.. – Peter Bernier Dec 09 '10 at 14:55
  • 1
    No not possible using only HTML + CSS – PeeHaa Dec 09 '10 at 16:13