brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: font-synthesis: none in CSS stops the browser from faking bold and italic

Css
~/tips/tip-css-font-synthesis-none

font-synthesis: none;

Text without a real bold or italic font file stays in the designed style instead of a smeared imitation.

If you load only the regular weight of a font and then write <strong>, the browser invents a bold by smearing the letters. Italic gets the same treatment with a slant. font-synthesis decides whether that is allowed.

.logo,
.brand-heading {
  font-synthesis: none;
}

/* or more selective */
:lang(ja) {
  font-synthesis: style;
}

none blocks all synthesized styles. You can also list what is still allowed: weight, style, small-caps and position (for fake superscript and subscript, so far only in Firefox). The second rule above only allows a fake oblique for Japanese text and forbids a fake bold, since synthesized bold can make complex characters unreadable.

I’d use it mainly on logos and display fonts where a fake bold looks clearly wrong, and on icon fonts where it can distort shapes.

The catch is obvious once you think about it: if the font has no bold file and you forbid the fake one, bold text looks the same as normal text. So either load the real weights you use or accept that strong loses its look in that element. The property is supported everywhere current: Chrome 97, Firefox 34 and Safari 9.

Further reading: MDN: font-synthesis

More Css tips CSS Overview in Chrome DevTools audits the colors and fonts of a page .notice:empty { .toast { article { counter-reset: h2; } .toolbar { All Css tips (66) All topics

Link