Better Programming

Advice for programmers.

Follow publication

Member-only story

Improving Font Rendering With CSS

Mate Marschalko
Better Programming
Published in
4 min readJan 5, 2016

I think most front-end developers have accepted that fonts in the browser, and especially the ones on those large headings, look very different than what we see in Photoshop.

The fonts are a bit thinner, smoother, and generally much, much better in PS. We can’t really change the way fonts are rendered in the browser, but for some of them, we can use a simple CSS trick to achieve Photoshop-like quality. In WebKit, we will use the -webkit-font-smoothing property. Firefox has also implemented a similar property called -moz-osx-font-smoothing, and it’s available from version 25. Try adding these properties to your heading tags or to the whole body:

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;

Let’s have a look at the dramatic difference this makes on OSX:

Without and with antialiasing

This will work nicely on Chrome, Safari, and Firefox on a Macintosh computer. If your text is a bit too thin and blurred in WebKit browsers (especially when CSS transform is applied to the container), you can try adding some -webkit-text-stroke with a value lower than half a pixel. Something around 0.15–0.45px should work. For other font sizes or colours, adding a…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Mate Marschalko
Mate Marschalko

Written by Mate Marschalko

Senior Creative Developer, Generative AI, Electronics with over 15 years experience | JavaScript, HTML, CSS

Responses (8)

Write a response

Adding a text-stroke to solve the font thinning problem is a great tip Mate Marschalko. However, using -webkit-font-smoothing: subpixel-antialiased; can make your fonts appear slightly thicker.
While you’re at it, you might also want to use text-rendering: optimizeLegibility; for better readability.

Whattt how didnt i knew that already, great article!!!