How to bold the first option of a select across all browsers?

旧街凉风 提交于 2019-12-01 17:18:52
#htmldisabled:first-child{
    font-weight:bold;
}
danwellman

As you've discovered, it can't be done cross-browser ;)

Best to use a selectbox replacement script if you need special formatting or display

To my knowledge it doesnt work in IE unless you style the select tag:

select{
    font-weight:bold;
}

However this will influence all options. I dont know of another css-only solution, but would be interested in one as-well :)

Just try,

css

option:first-child {
     font-weight:bold;   
   }

HTMl

<select id="htmldisabled">
    <option>test1</option>
    <option>test2</option>
    <option>test3</option>
    <option>test4</option>
    <option>test5</option>
    <option>test6</option>
</select>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!