I’m trying to change the color of the select option which has the value of "".
This is the HTML I have:
<select id="kategorija" name="kategorija"></select>
This is the CSS I have:
select {
border-radius: 5px;
height: 45px;
background-color: #f6f6f6;
border-width: 0;
text-indent: 10px;
}
select:invalid {
color: green;
}
I’ve tried multiple options found here but none seem to be working.
Also, is there a way to put padding around the arrow of the select option?
2
Answers
maybe what you mean is this
visit : https://www.w3schools.com/cssref/sel_invalid.php
We’re not styling an
<option>
here, we are conditionally styling the<select>
itself. And if you set the text color to green when there is no text displayed, you won’t see any change. Suggest you start by styling the border when the select is:invalid
, and then go from there. And remember, for this to work, the select needs therequired
attribute in order for a blank option to be considered invalid.