Skip to content

Commit

Permalink
Add more information about rem units and padding
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBiddle committed Apr 5, 2023
1 parent 4e13ff8 commit 84de505
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions source/manuals/programming-languages/css.html.md.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ You should use the [GOV.UK Design System spacing scale](https://design-system.se

If your project is not using the GOV.UK Design System, you should use pixel values in multiples of `5px`.

### Use `rem` units for font size, but not for spacing
## Use `rem` units strategically

Use `rem` units for font sizing wherever possible. This allows users to increase the size of the text on a page by adjusting the font size in their browser settings.
As a general rule, per [Josh W. Comeau's _The Surprising Truth About Pixels and Accessibility_] (https://www.joshwcomeau.com/css/surprising-truth-about-pixels-and-accessibility/#strategic-unit-deployment-6):

Avoid using `rem` units for spacing - use `px` instead.
> When picking between pixels and rems, here's the question you should be asking yourself: Should this value scale up as the user increases their browser's default font size?

Use `rem` units for `font-size` wherever possible.

You should generally avoid using `rem` for padding or border-width if these are likely to cause layout or readability issues when the font-size increases.

## Vendor prefixing

Expand Down

0 comments on commit 84de505

Please sign in to comment.