I've always been curious as to why the <select>
element appears in different colors on various web pages. I've noticed that when the font-family:inherit
css property affects the select element, it ends up looking blue!
<!-- BLACK -->
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
<!-- BLUE -->
<select style="font-family: inherit;">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="opel">Opel</option>
<option value="audi">Audi</option>
</select>
Check out this JsFiddle for a working example.
Even though I have experience in frontend development and I'm familiar with normalize/reset techniques, I'm still puzzled by why setting font-family:inherit
affects the color of a <select>
.
Can anyone shed some light on this? What exactly is the default value of font-family (i.e. inherit) supposed to do?
Take a look at this screenshot showing the result from the js fiddle on a Mac.
EDIT:
Tony shared a screenshot in the comments, pointing out that font-family: system-ui;
also impacts the appearance of the <select>
element.
EDIT 2:
It seems that using the trend in web design to let the device decide on the font family - known as native fonts - causes forms to adhere to this directive, resulting in them being rendered as native UI elements.