Is there a css selector to match a option value of the select tag?

user1214678 picture user1214678 · Jul 24, 2015 · Viewed 26.9k times · Source

For example:

<select>
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
</select>

I want to select the option where value = one, but I must select using the value attribute.

I've tried a few variations as the ones below:

option[value="one"]{
}

select[value="one"]{
}

select option[value="one"]{
}

Answer

indubitablee picture indubitablee · Jul 24, 2015

option[value=two] { 
    background-color: yellow;
}
<select>
<option value="one">1</option>
<option value="two">2</option>
<option value="three">3</option>
</select>