// I need to

ModernizeUpgrade without breaking it RescueFix what someone else started Build NewTurn an idea into a product Reach More PeopleGet found, get used, include everyone

// Company

Case StudiesExpertiseAbout + CareersResourcesContact Book a call →

Oh, drop downs, you cheeky little things!

Native select menus resist CSS styling. A simple way to fully customize a drop down without jQuery: wrap the select in a styled div, with code.

Daisey Traynham Feb 26, 20132 min read

From the Art+Logic archive · written in 2013. The tools may have moved on; the thinking still holds.

Photo by Ferenc Almasi on Unsplash Software screen capture

Why is it? Form elements are fully customizable using simple CSS styling except <select> drop downs. Oh sure, you can tweak colors, sizes, fonts, etc. but I’m talking about overriding the native controls and really making them your own. Of course, you can use jQuery, which is an excellent solution in most cases, but sometimes introducing additional scripts can interfere with what’s going on under the hood.

I recently stumbled upon a neat concept, and after a little wrangling, I was surprised to have found a pretty simple way to override the native <select> drop down. Oh, happy day!

Here’s a basic drop down:

<select>
  <option>Option</option>
  <option>Option</option>
</select>

And here it is, natively ranging from hi-tech glossy to just plain ugly:

Throw a few color styles on it and you get this…

But we’re trying to achieve something more like this…

Software screen capture

What we want to do is wrap the select in a div. We already know a div can be fully customized: round corners, image backgrounds, gradients, etc. So, we’re basically styling the background container for the select.

<div class="style-select">
   <select>
      <option>Option</option>
      <option>Option</option>
   </select>
</div>

Here’s what we have so far, wrapped in a styled div…

I’m using a lighter shade of grey to illustrate how the select is sitting inside the div container, but we’re going to set the background to transparent anyway, so it looks like this…

To customize the arrow, we add a right aligned background image to the containing div, like so…

Now, let’s set the overflow to hidden and scoot that blocky native arrow out of the way by setting the <select> width to 120%.

Software screen capture

The <select> is still there, but it’s wider than the container, so it’s technically off the radar. Overflow is set to hidden, so anything beyond the size of the containing div is clipped.

Here’s the final CSS for the select and its styled containing div.

.styled-select select {
   background: transparent;
   width: 120%;
   padding: 4px;
   font-size: 12px;
   color: #999;
   -webkit-appearance: none;
   }
.styled-select {
   width: 145px; 
   height: 24px;
   overflow: hidden;
   background: url(dropArrow.png) no-repeat right #515151;
   -webkit-border-radius: 4px;
   -moz-border-radius: 4px;
   border-radius: 4px;
   }

This works beautifully on Safari, Chrome and Firefox. As expected, IE doesn’t display the dropdown as we ultimately designed it, but it gracefully ignores the styles and only displays the semi-styled native <select>

And with a few minor viewport and size tweaks, it also works on mobile. Bonus!

keep going

More to explore in Reach More People.

All Reach More People resources →
let's talk

Got a problem like this one?

Tell us what's stuck. A real person replies within one business day.

Talk to our team →

Talk to people who know software, not a sales script.

Your first call is with Aja, our VP of Sales. He'll help make sure you're solving the right problem. Here's what you'll cover together:

  1. What you're trying to accomplish

    The business goal first, then the technology.

  2. Possible approaches

    And the tradeoffs of each, in plain language.

  3. Risks you may not have considered

    Technical and business, before they cost you.

  4. Whether AI changes the math

    What's practical, and what's just hype for your project.

  5. Sensible next steps

    Even if the right next step is not us.

book-a-call.ics

Loading the scheduler…

Open the booking page →

Some problems are easier to explain in writing. Send us a few lines about what you're working on, and we'll reply within one business day. Helpful to include:

  1. What the software does, or should do
  2. What's stuck, or what's worrying you
  3. Any deadline or budget you have in mind
note.md

Loading the form…