3

I know this is an extremely basic and stupid question, but I seem to be having a genuinely curious problem.

When using what are supposed to be web-safe fonts like Didot, and using

header h1{
font-family: Didot, serif;
font-size: 36px;
}

my browser just displays the standard serif font.

In fact I can't seem to get it to display any web safe font, it will only display either the standard serif or sans-serif font. I know my selector is correct because I CAN change between serif and sans-serif, but I know its not displaying other web-safe fonts because I tried both Arial and Helvetica (which are both definitely web safe) and when I refreshed from one to another there was absolutely no difference in the font displayed.

I'm a complete beginner and I'm using the simplest possible beginner environment, just an html page linking to a css file which I'm opening with my browser (the url shows up as file:///C:/Users/Agent%201/Desktop/Web%20Projects/ResumeSite/index.html if that is at all relevant). I've tried opening it with both chrome and edge, same results on both

Is there something wrong with my css? Or are there limitations when just opening a local html file with my browser?

Sorry if I'm this is a really dumb question, but I really can't find an answer as to why my fonts aren't working, I've tried !important and some other weird solution I found which involves changing the selector to "header h1, header h1 *" and that did nothing.

Thank-you for any help you can provide me!

1 Answers1

5

When using what are supposed to be web-safe fonts like Didot, and using...

  • Didot is not a "web-safe" font.

    • Didot is included with macOS, which may lead some web-designers to assume that it's also available on other platforms (like Windows, Linux and Android) or that those platforms have automatically-mapped equivalents (like how many browsers will map Helvetica to Arial), however that is not guaranteed.
      • Also, just because a typeface is included with an OS does not mean it is licensed to you to use commercially or in a website - you can be sued for publishing an OS-licensed font onto the public web without having your own font-license.
  • A "web-safe" font is a typeface that is broadly installed and supported by most contemporary browsers without the need for additional downloads or font installations.

    • Many typefaces are broadly installed, such as Microsoft's Core fonts for the web which are preinstalled on all Windows computers - and many other operating systems such as macOS either come with the same fonts or have very similar equivalents (e.g. Helvetica instead of Arial) which are automatically mapped by the browser.
  • The only way to determine if a font is "web-safe" is by doing your own leg-work and manually checking to see if all-or-most of your target users' devices have that typeface available. You can check font availability on Wikipedia and other sites:

A "web-safe font stack" means that at least one of the fonts listed in a font-family property value can be safely assumed to be available for use, not that all of them are - nor that the first-preferred-font will be available.

And any font-family list can be made "safe" by adding a CSS fallback generic-family name to the end (i.e. specifying the least-preferred font). Those names are specified in the CSS Fonts Module and are:

  • serif
  • sans-serif
  • cursive
  • fantasy
  • monospace

In your case, the property font: Didot, serif is "web-safe" because it has the serif generic-family name at the end. Your visitors will only see the Didot font being used if they already have it installed on their computer, phone, tablet, etc.

If you do want to use Didot, then you need to publish it as a WOFF file and add it to your stylesheet with a @font-face rule: https://css-tricks.com/snippets/css/using-font-face/

Dai
  • 141,631
  • 28
  • 261
  • 374
  • How you decide what is a web safe font and what isn't? E.g. here(https://blog.hubspot.com/website/web-safe-html-css-fonts) Didot is in the list of web safe fonts. – Martian Mar 19 '21 at 14:37
  • @Martian That article you linked to is a *non-authoritative* low-information (likely content-farmed) writing designed to boost HubSpot's search-engine results by giving their website more "genuine" content. Notice how the article never explains what a "web-safe font" is on a technical level. I don't know how they chose the fonts in their list, but it's nonsense - because half of the fonts listed are exclusive to macOS (you can see Didot and Luminari here: https://en.wikipedia.org/wiki/List_of_typefaces_included_with_macOS You have to pay $30 to license Luminari for web use from MyFonts.com) – Dai Mar 19 '21 at 16:01