Load the default OS font with CSS
- Published at
- Updated at
- Reading time
- 2min
I'm no font person. Sometimes, I notice a nice font setup, but I don't have the eye for it, and I appreciate the performance boost of not loading custom fonts.
That's why this blog (at the time of writing) aims to render the default operating system fonts. After reading Stoyan's post on system fonts I could just do a little spring clean up.
Here's the default CSS font setup I shipped for ages:
body {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
}
It's one of these snippets you carry over from project to project. This font-family
declaration tries to find installed fonts from left to right. It starts with -apple-system
and BlinkMacSystemFont
. And guess what? These two font-family
values are relics from the past that you don't need in 2025.
Today, there's a CSS value to load the default operating system font, which is supported everywhere — system-ui
.
As MDN states:
Glyphs are taken from the default user interface font on a given platform.
Cool! By using system-ui
as default font, I could clean up a bit of CSS and go with this beauty.
body {
font-family: system-ui, sans-serif;
}
Nice and clean. This site will now render
on MacOS, and I don't have a Windows machine, but it seems to be Segoe UI
. But whatever is available on the OS does the trick for me.
Theoretically, there are also values for more granular system fonts:
ui-serif
for the default user interface serif font.ui-sans-serif
for the default user interface sans-serif font.ui-monospace
for the default user interface monospace font.ui-rounded
for the default user interface font that has rounded features.
These are support only by Safari since 2020.
If system font topic is interesting to you, Jim did a lovely deep-dive into the topic (thanks, Sarah, for pointing me towards this article). Check it out, it's great!
Join 5.6k readers and learn something new every week with Web Weekly.