3

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.

Community
  • 1
  • 1
Chirag
  • 994
  • 2
  • 11
  • 26
  • Chiraj, did you really check for answers to this already answered question. There are tonnes of questions and references that we cannot style the `option` and why. – Deepak Yadav Apr 14 '17 at 06:24
  • @DeepakYadav I don't want to know how to style it. I want to know why we can't style it. – Chirag Apr 14 '17 at 06:25
  • @DeepakYadav yes, I did it. But there is not even a single satisfying answer as everyone is stating that it's rendered by OS. I want to know detailed answer. – Chirag Apr 14 '17 at 06:26
  • @DeepakYadav I've already stated that question in my post and I stated it too that it is saying that option is rendered by OS. But I want detailed answer on it. I'm not satisfied by that single statement. Why it's rendered by OS what is reason behind that.? So please don't get me wrong. I've had already reffered all those questions. – Chirag Apr 14 '17 at 06:31

2 Answers2

3

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.

Tom Udding
  • 2,264
  • 3
  • 20
  • 30
  • That answer is already given in the question itself. The author said he wants to dig deeper into that. – Robert Kusznier Oct 25 '18 at 12:49
  • 2
    @RobertKusznier I provided this answer before the original question was edited (which you can check by comparing the timestamps). Since I do not get notified of such updates, I have never seen the updated question. As per why you cannot style it: the browser decides what to do with it, and that is it. That is how it is implemented. You should ask the developers of the browsers why it is like that. – Tom Udding Oct 25 '18 at 13:53
-1

There a duplicate method for this... its correct dropdown not accept the styling so you can make the thing which look like dropdown and give styling to that thing.. Here is the link of this explaination check Answer7

css style on select option

Community
  • 1
  • 1
hammad
  • 74
  • 3
  • 14