Skip to content

Instantly share code, notes, and snippets.

@alexilyaev
Created December 10, 2020 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexilyaev/ebd052c601851e8b89cee56853a19c41 to your computer and use it in GitHub Desktop.
Save alexilyaev/ebd052c601851e8b89cee56853a19c41 to your computer and use it in GitHub Desktop.
CSS Styling Guidelines

CSS Styling Guidelines

  • Use rem units for font-size and line-height.
    • The user preferences are respected.
    • We can change the apparent px value of rem to whatever we'd like.
  • Use px, % or vw for layout purposes.
    • For example, when using margin, padding, width, height, etc.
    • Easier to implement design requirements.
    • Why not rem here as well?
      • Layout can break when changing the base browser font-size.
      • If users go through the trouble of changing the browser Font Size (instead of the Zoom feature), they usually expect only the font size to change.
    • Rare cases:
      • If an element box directly depends on the text inside it (only when the font size is fluid based on screen size), use em for layout (not rem).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment