According to sitepoint (a source I typically highly trust) when specifying font-family
names some Operating Systems/Browsers may be case-sensitive.
I've typically always used mixed-case values but I'm wondering if lower-case values will work just the same?
I don't have an overwhelming preference either way - but I'd hate for a page to render differently because I typed a lower-case "v"
vs. "V"
somewhere in a CSS file.
e.g. are there any known cases where 2 divs with the foo
and bar
classes below would actually render with a different font?
div.foo{
font-family:Verdana, Arial, Helvetica;
}
div.bar{
font-family:verdana, arial, helvetica;
}
CSS syntax is case-insensitive within the ASCII range (i.e., [a-z] and [A-Z] are equivalent), except for parts that are not under the control of CSS. For example, the case-sensitivity of values of the HTML attributes "id" and "class", of font names, and of URIs lies outside the scope of this specification.
You don't have to capitalize the font-family name. The W3C standard requires that browsers match font names case insensitively using a specific algorithm. In fact, web browsers have treated font-family names case insensitively long before that standards document made it official.
In CSS (and in typography in general) there are five basic types, or families, of fonts: serif, sans serif, cursive, fantasy, and monospace.
The font-family property holds several font names to provide a "fallback" system. The browser tries each font family in the order that they are listed; if the browser does not support the first font, it tries the next font, and so on, down the list.
Although the CSS syntax overview says
The following rules always hold: All CSS style sheets are case-insensitive, except for parts that are not under the control of CSS. For example, the case-sensitivity of values of the HTML attributes "id" and "class", of font names, and of URIs lies outside the scope of this specification. Note in particular that element names are case-insensitive in HTML, but case-sensitive in XML.
The css3-fonts module section mandates case-insensitive comparison:
For other family names, the user agent attempts to find the family name among fonts defined via @font-face rules and then among available system fonts, matching names with a case-insensitive comparison.
so the CSS3 specification requires that font-names be treated case-insensitively.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With