I want to add class for my option element. Is that valid to add class attribute in HTML option element?
The class
attribute is valid for option
according to the relevant part of the HTML 4.01 Recommendation. The HTML5 drafts, including HTML5 CR, are even more permissive: they allow class
literally on any element.
My guess is that what you really wanted to ask was whether you can style some option
elements differently from others, using class
attributes and CSS. Then the answer is that this depends on browser – not due to problems with recognizing class
attributes but due to implementations of that are partly immune to CSS as regards to styling items in a dropdown list.