Skip to content

Instantly share code, notes, and snippets.

@KnightAlex
Last active October 14, 2015 13:43
Show Gist options
  • Save KnightAlex/6df9713fda629f11acb7 to your computer and use it in GitHub Desktop.
Save KnightAlex/6df9713fda629f11acb7 to your computer and use it in GitHub Desktop.
Font % resize trick
html {
font-size: 62.5%;
}
body {
font: 1.6em/1.4 'Roboto', sans-serif;
}
@KnightAlex
Copy link
Author

A popular technique to use throughout the document is to set the the font-size of the body to 62.5% (that is 62.5% of the default of 16px), which equates to 10px, or 0.625em. Now you can set the font-size for any elements using em units, with an easy-to-remember conversion, by dividing the px value by 10. This way 6px = 0.6em, 8px = 0.8em, 12px = 1.2em, 14px = 1.4em, 16px = 1.6em.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment