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!
Didot is not a "web-safe" font.
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.
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:
fonts.xml
for the minimum set of stock fonts and default fallback mappings (e.g. "Helvetica" goes to "sans-serif").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 theserif
generic-family name at the end. Your visitors will only see theDidot
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/