简体   繁体   中英

How to style span tag of option text in html select

Stackblitz

I have a scenario where the first option of my HTML select includes an asterisk which is supposed to be in a red color. However I am unable to style the asterisk and it always appears in the default black color.

I have included the stackblitz example and even if i use an image of asterisk it still does not work as intended.

You can't just style the span tag, because only plain text can be placed in the option element. So actually there is no span tag. 在此处输入图像描述 But you can add style to select, and color will be red in select element.

 select { color: red; }

Stackblitz

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM