How to change the style of a Select box' optgroup label

css style select option dropdown
css style select option dropdown codepen
style select option css
ios select box styling
css style multiple select option
css select option padding
pure css select dropdown
select option css not working

I have a simple select box with an optiongroup in my application.

   <optgroup label="Swedish Cars">
     <option value="volvo">Volvo</option>
     <option value="saab">Saab</option>

When it gets displayed in browser, the option group label is displayed with bold and italic; I want it to be displayed without any of those styles.

Unfortunately select boxes are one of the few things that you can add very little style to with CSS. You are usually limited to how the browser renders it.

For example, it looks like this in chrome:

And this in Firefox:

How to style the option of an html "select" element?, There are only a few style attributes that can be applied to an <option> element. This is because this type of element is an example of a "replaced element". Enter the solution: The first method allows you to change the basic styles of a select field, not including the option styles, and is quite easy to implement. So, let’s begin. So, let’s begin. The HTML

On most browsers (tested on latest IE and FF), you can easily change the optgroup's label with CSS only:

    select optgroup{

Obviously, you can set any classname instead of the select html tag.

By the way, as other answers said, there are still few CSS options to use with select boxes and many webmasters override them using the method given by user949847. But this code above should be sufficient to match your needs.

Dropdown Default Styling, Firefox, Opera, and IE will respect your change. The font-family won't It will also allow your font size and style choices to come through. When you select an option it displays the custom styling again with the choice shown. It's a lot of work​  <select> <option>Here is the first option</option> <option>The second option</option> </select>. There are certain elements of a select box that we can style such as the font, border, color, padding and background color: But that annoying drop down arrow always stays the same.

Firefox style the label using this rule :

optgroup:before {
    content: attr(label);
    display: block;

You can override it.

Styling a Select Like It's 2019, The select element has long been difficult to style consistently across browsers. <option>This is a native select element</option> If you change the icon image, be aware that its size is set in the first section of the later  C ollection of free HTML and CSS custom select box code examples: dropdown, multiple, custom arrow, etc. Update of June 2018 collection. 4 new items. Custom select box dropdown styling. Dependencies: font-awesome.css. Pure CSS select box without any JavaScript. When there is hover on an option the motion of icon inside option is decided by the

You can style a select box using only css, it requires a sort of work around:

First, you surround it with a div and give that a class:

<div class="selectStyle">
        <option>First Option</option>
        <option>Second Option</option>

Then you make sure the select elements are styled a certain way using css:

.selectStyle select {
   background: transparent;
   width: 250px;
   padding: 4px;
   font-size: 1em;
   border: 1px solid #ddd;
   height: 25px;

And you style the div:

.selectStyle {
   width: 235px;
   height: 25px;
   overflow: hidden;
   background: url(yourArrow.png) no-repeat right #ccc;

How to Style a <select> Box Drop-down with Only CSS?, How to style the select box. Learn 4 ways of replacing the annoying drop-down arrow and setting either a background-image instead of it or a punctuation mark. When you run this code on any page within a WebKit-based browser it should change the appearance of the select box, remove standard OS-arrow and add a PNG-arrow, put some spacing before and after the label, almost anything you want. The most important part is appearance property, which changes how the element behaves.

For a different approach to circumvent the problems with styling optgroups i suggest using disabled options.

<option disabled>[group label]</option>

you can have a shot on styling it via eg.

<style> [disabled] { color:#000; background-color:#CCC } </style>

How to Create A Custom Select Box, Custom Select An Option. Custom select, designed to change the typical style of the select in browsers, using JS to display the list when it clicks,  There are only a few style attributes that can be applied to an <option> element.. This is because this type of element is an example of a "replaced element". They are OS-dependent and are not part of the HTML/browser.

How to Style and Customize HTML Select Box Created by Select , Dropdown menu is mainly used to select an element from the list of elements. Example 1: This example contains the dropdown CSS property to display the  Each browser displays select elements differently and it’s usually the one thing that will stop your forms from looking amazing. Where is with a regular button it’s fairly easy to change it, changing the selector arrow is another story.

28 CSS Select Boxes, Style a Select Box Using Only CSS. Inspired by:​select-box-using-only-css/ This step-by-step tutorial explains “how to style a select box using CSS and jQuery”.At the end of this tutorial, you will learn traversal, manipulation and event handling in jQuery and data-attributes in HTML.

How to style a dropdown using CSS?, In this video I will change the select box arrow. You can find more information about this video at

  • So which means we cant override the style browser using for display optiongroup labels, in above screenshot Swedish cars and American cars?i wan to display those labels in Normal font weight for all browsers. I want to display that in normal font for all browsers.
  • Yeah, you cant do that with CSS, its part of the browser's chrome, unfortunately.
  • this is no longer the case, you should look at the latest answers
  • It is the case as of this writing; although, the display is not consistent across all browsers.
  • Working in IE10, FF21, Chrome28, and Opera12 as of this date. (Sorry, don't have Safari installed!) Note: On most of the mentioned browsers, the entire <optgroup> section is styled, not just the label.
  • If you apply styles to option tags as well as to optgroup tags, you can effectively control the presentation of the label without altering the standard presentation of the list items.
  • FYI this is not working on Safari and Chrome under OSX. It still works on FF.
  • i want to style only optgroup Label
  • Then you simply target the optgroup: optgroup[label="Swedish Cars"]
  • Gnanz is talking about the label attribute. Being specific about the optgroup doesn't really address his problem.
  • I noticed that this doesn't style on mobile devices. Is there a way to do that?
  • Please improve your answer by adding some explanation of your code.
  • Simple put style in head html
  • I upvoted it... just because it was not needed more explanation when the code is obvious. Is similar to comment a source code for actions that are obvious seen in the code itself. And, because I just copied and pasted it in my CSS and the group was styled perfectly :-)