Sometimes, we want to style the option of an HTML select element with CSS.
In this article, we’ll look at how to style the option of an HTML select element with CSS.
How to style the option of an HTML select element with CSS?
To style the option of an HTML select element with CSS, we can apply styles to the option element.
For instance, we write
<select>
<option>Some normal-font option</option>
<option>Another normal-font option</option>
<option class="boldoption">Some bold option</option>
</select>
to add a select element with an option element having the boldoption
class.
Then we write
.boldoption {
font-weight: bold;
}
to boldoption
class has font weight bold.
Conclusion
To style the option of an HTML select element with CSS, we can apply styles to the option element.