How to style the options of the HTML "select" element?
P粉208469050
P粉208469050 2023-08-20 12:33:38
0
2
394

This is my HTML code:

I want to bold the product names (i.e. 'Product 1', 'Product 2', etc.) and italicize their categories (i.e. Electronics, Sporting Goods, etc.) using CSS. I found an old question mentioning that it's not possible using HTML and CSS, but hopefully there is a solution now.

P粉208469050
P粉208469050

reply all (2)
P粉156532706

No, this is not possible because the styling of these elements is handled by the user's operating system.MSDN will answer your questions here:

    P粉825079798

    Only a few style attributes can be applied toelements.

    This is because this type of element is an example of a "replacement element". They are operating system dependent and not part of HTML/browser. It cannot be styled via CSS.

    There are alternative plugins/libraries that look like

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!