Skip to main content
Remove [option] tag as per https://meta.stackoverflow.com/questions/266719/the-option-tag-is-being-burninated
Link
dbc
  • 119.7k
  • 27
  • 273
  • 404
added 328 characters in body
Source Link
Thomas
  • 323
  • 1
  • 4
  • 15

Quite simply, is there any way to style specific select options in Chrome/Safari?

For example, if I had:

<select class="the-select">

<option class="header">TECHNICIANS</option>
<option>Joe Smith</option>
<option>Joe White</option>
<option class="header">PRODUCERS</option>
<option>Jane Black</option>
<option>Cindy Gray</option>

</select>

Is there anyway to style specifically those options with the class "header"? Obviously in CSS, if you do this:

select.the-select option.header {
    background-color:#ff9900;
}

This should work, and does in other browsers, but not Chrome/Safari. Is this just a webkit issue and are there any workarounds for this?

Thanks!

EDIT: This seems to be an OSX webkit based browser issue, as it seems to work on Windows. I neglected to mention the fact that I cannot use optgroups because we need to be able to select those options as well. I am aware that optgroups would be the ideal solution, but unfortunately that cannot be the case in this instance.

Quite simply, is there any way to style specific select options in Chrome/Safari?

For example, if I had:

<select class="the-select">

<option class="header">TECHNICIANS</option>
<option>Joe Smith</option>
<option>Joe White</option>
<option class="header">PRODUCERS</option>
<option>Jane Black</option>
<option>Cindy Gray</option>

</select>

Is there anyway to style specifically those options with the class "header"? Obviously in CSS, if you do this:

select.the-select option.header {
    background-color:#ff9900;
}

This should work, and does in other browsers, but not Chrome/Safari. Is this just a webkit issue and are there any workarounds for this?

Thanks!

Quite simply, is there any way to style specific select options in Chrome/Safari?

For example, if I had:

<select class="the-select">

<option class="header">TECHNICIANS</option>
<option>Joe Smith</option>
<option>Joe White</option>
<option class="header">PRODUCERS</option>
<option>Jane Black</option>
<option>Cindy Gray</option>

</select>

Is there anyway to style specifically those options with the class "header"? Obviously in CSS, if you do this:

select.the-select option.header {
    background-color:#ff9900;
}

This should work, and does in other browsers, but not Chrome/Safari. Is this just a webkit issue and are there any workarounds for this?

Thanks!

EDIT: This seems to be an OSX webkit based browser issue, as it seems to work on Windows. I neglected to mention the fact that I cannot use optgroups because we need to be able to select those options as well. I am aware that optgroups would be the ideal solution, but unfortunately that cannot be the case in this instance.

Source Link
Thomas
  • 323
  • 1
  • 4
  • 15

Pure CSS solution to styling specific <select> options in webkit based browsers?

Quite simply, is there any way to style specific select options in Chrome/Safari?

For example, if I had:

<select class="the-select">

<option class="header">TECHNICIANS</option>
<option>Joe Smith</option>
<option>Joe White</option>
<option class="header">PRODUCERS</option>
<option>Jane Black</option>
<option>Cindy Gray</option>

</select>

Is there anyway to style specifically those options with the class "header"? Obviously in CSS, if you do this:

select.the-select option.header {
    background-color:#ff9900;
}

This should work, and does in other browsers, but not Chrome/Safari. Is this just a webkit issue and are there any workarounds for this?

Thanks!