Determining Appropriate Font Names Using CSS: Windows, MacOS, Linux
When working on a website, you want to make sure that the typography looks great on any platform. This article will help you understand how to determine appropriate font names using CSS, regardless of whether you are working on Windows, MacOS, or Linux.
Understanding the font-family property
In Cascading Style Sheets (CSS), the font-family property allows you to specify the font(s) used to render text content. You can set one or more font names as a prioritized list, separated by commas. When the browser loads the webpage, it will try to use the first font specified in the list. If for some reason it can't find or use that font, it will move on to the next one.
body {
font-family: 'Roboto', sans-serif;
}
Platform-specific font names
While many popular fonts are available on all platforms, sometimes you will encounter platform-specific font names that you want to leverage on those platforms only. Below you will find the list of CSS selectors to target specific operating systems:
:-webkit-full-screen– for Chrome on MacOS:-webkit-internal-host-full-screen– for Safari on MacOS:-moz-full-screen– for Firefox on Windows, MacOS, and Linux
You can also target Windows, MacOS, and Linux specifically:
:-webkit-full-screenand not:-webkit-internal-host-full-screen– for Chrome on Windows and Linux:not(:-webkit-full-screen)and:-webkit-internal-host-full-screen– for Safari on Windows
Determining installed fonts using developer tools
While you're working on your website, you can leverage your browser's developer tools to easily determine which fonts are actually installed on your system. This is crucial for finding the right fallback fonts and troubleshooting issues with inconsistent typography rendering.
Google Chrome
In Google Chrome, open the developer tools (Ctrl + Shift + I or Cmd + Option + I) and go to the Computed tab. Under Font Family, you will see the complete list of fallback fonts in the order they are being applied.
Mozilla Firefox
Mozilla Firefox has a similar feature in the developer tools. You can open it by pressing Ctrl + Shift + C or Cmd + Option + C on your keyboard. Go to the Computed tab, and look for font-family in the list. This will display the effective font stack used on the page.
List of popular fonts on all platforms
If you'd like to provide consistent typography across all platforms, here's a list of extensively used fonts on Windows, MacOS, and Linux that you can include in your font-family list:
- Arial
- Helv