Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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