HTML CSS examples for CSS Widget:Color
Change color of default option in select
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style id="compiled-css" type="text/css"> .my {<!-- w w w . j a v a 2 s .com--> -webkit-appearance: button; -moz-appearance: button; appearance: none; -webkit-user-select: none; -moz-user-select: none; background-color: #fff; display: inline; box-sizing: border-box; height: 33px; width: 132px; border: 1px solid #ababab; border-radius: 5px; cursor: pointer; padding-left: 13px; background: url('https://www.java2s.com/style/demo/Safari.png') 100% 0% no-repeat #fff; color: black; } .my .green { color: green; } .my .red { color: red; } </style> </head> <body> <p>With visible default</p> <select id="year-ready" name="" class="my"> <option disabled selected>Year...</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> <option>2021</option> </select> <br> <p>With invisible default</p> <select id="year-ready" name="" class="my"> <option hidden disabled selected>Year...</option> <option>2017</option> <option>2018</option> <option>2019</option> <option>2020</option> <option>2021</option> </select> <br> <p>With classes</p> <select id="year-ready" name="" class="my"> <option class="green" disabled selected>Year...</option> <option class="red">2017</option> <option class="red">2018</option> <option class="red">2019</option> <option class="red">2020</option> <option class="red">2021</option> </select> </body> </html>