Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why we can't style option of dropdown using CSS? [duplicate]

In Css we can genrally style all elements but I noticed that we can not style option element of a select using CSS. As far as I know Option is child element of select then what is possible causes that it don't let you style this element?

I've had reffered various answers on stackoverflow stating that You just can't style option. but I want to know exact reason behind it.

I've had reffered this link which says that option tag is rendered by OS and not by html. If so then why we need to specify option ? why it don't automattically render options.

Here is another link which shows how to style Select tag. But i want to know that why we can't style option? I don't want to know how to style select tag using CSS.

like image 890
Chirag Avatar asked Sep 06 '25 03:09

Chirag


1 Answers

You cannot style the option element because it is rendered by the OS, not HTML. That is why it can't be styled via CSS.

You can of course use some plug-in that replaces select with regular HTML elements that can be styled.

like image 191
Tom Udding Avatar answered Sep 07 '25 21:09

Tom Udding