There has always been big differences across how different browsers handle form styling. There probably always will be – because UI design choices aren’t described in the specs. Browser makers perhaps view this as one of the ways they can differentiate the user experience a bit. Select (dropdown) menus are one that is particularly weird.
When I say dropdown menu, I mean:
Left completely alone by CSS, this will render consistently across browsers. On Macs, 11px Lucida Grande.
Styling selects has changed a smidge since this article was written. Mid-2020 we still don’t have amazing styling control, but you can style the outside pretty well with this technique.
What if you change the font-family?
WebKit browsers (Safari, Chrome) will ignore you. Firefox, Opera, and IE will respect your change. The
font-family won’t cascade into the select though, you have to explicitly declare it on them.
What if you change the font-size?
This is a fun one. In WebKit, if the font-size is between 0 and 10px, it will render the font size as 10px. From 11px to 15px, it will render as 11px, and 16px or larger it will render it as (wait for it), 14px. This behavior is similar they handle search inputs.
Firefox, Opera, and IE will respect your change but again only if explicitly declared on the select, it will not cascade.
Can you get WebKit to respect your changes?
Kinda. You can set
border: 0; on the selects and it will make it look like a kinda crappy version of a dropdown but still have some UI. It will also allow your font size and style choices to come through.
You can also set
-webkit-appearance: none; and you’ll get what looks like a rounded corner input box, but still has the interactions of a select (click to reveal menu, keyboard commands, etc). It will also respect your font choices this way.
I’d say appearance is your best bet for fully custom dropdowns, but it would be WebKit only because while
-moz-appearance: none; works it doesn’t remove all the chrome, just some. Opera doesn’t support
appearance at all.
What about the dropdown itself?
As in, the thing that shows the choices when activated. As far as I know, there is no way to style these in any browser. Not even bold or italic. The closest thing to style you can get is grouping them by using
. This is probably mostly a UI thing, but it might be a security thing too. You wouldn’t want people doing tricky things with fonts that make it unclear what option is selected.
What if you want complete design control?
First, try everything you can to make that not necessary. Default form elements are familiar and work well. Making a dropdown menu match the font and colors of your brand isn’t usually necessary and is more likely obnoxious at best and bad UX at worst.
- Accessibly hide the original select.
- Rebuild the select with custom markup (probably a definition list), that you style how you want.
- Replicate all the functionality that default selects have, which include: keyboard events like up and down arrow keys and return to select, scrolling of long lists, opening the menu upwards when select is against bottom of screen, to name a few.
- For mobile, trigger the opening of the native select menu, because that functionality is just about impossible to replicate. For example, the iOS flipwheel.
- You might want to consider a “clickthrough” style for desktop as well. Have the select be custom styled by default, but when you click it, it opens the native dropdown menu (in place). When you select an option it displays the custom styling again with the choice shown.