Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On which operating systems or browsers are CSS font-family names case-sensitive

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;
}
like image 850
scunliffe Avatar asked Oct 21 '09 18:10

scunliffe


People also ask

Are CSS font names case sensitive?

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.

Are fonts case sensitive?

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.

What are some font families in CSS?

In CSS (and in typography in general) there are five basic types, or families, of fonts: serif, sans serif, cursive, fantasy, and monospace.

How does CSS font-family work?

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.


1 Answers

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.

like image 116
Mike Samuel Avatar answered Oct 07 '22 00:10

Mike Samuel