Sign in Get 3 free credits

Try a job or a niche: tiktok captions, study notes, excel formulas. Press Esc to close.

CSS sizing units

Picks the right CSS unit for each value, so your layout holds up when people enlarge text or zoom in.

What we improved

Corrected the 62.5% root advice. The original said `html { font-size: 62.5% }` overrides the user's preference by default. A percentage root actually scales with the user's setting; a px root is what overrides it. The section now separates

Improved by YourAISkill from the original by dembrandt, under its MIT licence. The download includes the author's licence and a CHANGES.md listing every change. Both Claude reviews read the improved version.

Claude's review

8/10 Clear, accurate decision table for CSS units tied to text scaling and WCAG, with token set, migration greps and a console check for clipped boxes.

We asked Claude the question you would ask: would I be glad I installed this? Two separate reviews, the second blind to the first, must both rate a skill 7 or higher before we sell it.

In detail

rem, px or relative units for each kind of value. Use when defining spacing and sizing tokens, control heights or media queries, or when a layout breaks under enlarged text.

How you use it

  1. Add it to your pack, then download your pack (1 credit).
  2. In Claude, open Customize > Skills and upload the zip. Code execution needs to be on under Settings > Capabilities.
  3. Ask Claude for the job in your own words. It uses the skill when your request matches what it does. Step by step guide

Safety check

Nothing risky found: no hidden instructions, no download and run, no reading of saved passwords or keys.

An automated scan lowers risk but cannot promise zero risk. How we check skills

Preview

The first lines of SKILL.md
---
name: sizing-units
description: Chooses the CSS unit for each kind of value (rem, em, px, %, fr, ch, viewport and container units, clamp()) by asking what should happen when a user enlarges text, zooms, or the available space changes. Covers type, line-height, spacing and control-height tokens, borders, radii and shadows, layout widths, min-height versus height, media and container query breakpoints, fluid type, the 62.5% root trick, Tailwind defaults, migrating a px codebase to rem, and testing at a 200% default font size. Use when defining spacing or sizing tokens, setting control heights or breakpoints, reviewing CSS for unit choices, answering "px or rem?", or fixing a layout that clips, overlaps or scrolls sideways when text is enlarged.
---
<!-- Modified by YourAISkill (youraiskill.com) on 2 December 2026 from the original by dembrandt. See CHANGES.md. -->

# Sizing Units

## The Question the Unit Answers

A unit is not a formatting preference. It is a declaration of what happens to a value when the user enlarges text.

- `rem`: this value belongs to the text and must grow with it.
- `em`: this value belongs to *this component's* text and must grow with the component's own font size.
- `px`: this value belongs to the screen and must stay put.
- `%`, `fr`, `ch`, `clamp()`, `min()`, viewport and container units: this value belongs to the available space.

Pick the unit by answering that question, not by picking a house style and applying it everywhere. Both absolutist positions, all-rem and all-px, produce defects, and they are different defects.

## Zoom Is Not the Font-Size Setting

The common argument for px everywhere is that browsers already have full-page zoom, so the root font size can be ignored. They are separate controls serving separate people.

- **Full-page zoom** magnifies everything, layout included. The viewport gets narrower in CSS pixels, so px media queries do respond to it. It buys larger text at the cost of fewer items per screen and, on a rigid layout, horizontal scrolling.
- **The browser's default font size** (Chrome and Firefox expose it in settings) changes what `1rem` means and leaves everything sized in px alone. This is what a user with low vision sets once, years ago, and never touches again. They will not switch to zoom because your product ignored it.

A product that hard-codes every dimension in px answers the first user and silently refuses the second.

What WCAG 2.2 actually requires, so you can argue it accurately:
- **1.4.4 Resize Text (AA):** text can be resized to 200% without loss of content or function. Browser zoom is an accepted way to meet it, so an all-px site can technically pass. Honouring the default font size is about real users, not a stricter reading of 1.4.4.
- **1.4.10 Reflow (AA):** content works at a width of 320 CSS pixels (a 1280px window at 400% zoom) without scrolling in two directions. Rigid px widths are what break it.
- **1.4.12 Text Spacing (AA):** nothing is lost when users override line height to 1.5, paragraph spacing to 2x, letter spacing to 0.12em and word spacing to 0.16em. Fixed heights on text boxes are what break it.

## Decision Table

| Value | Unit | Why |
|---|---|---|
| Font sizes | `rem` | Follows the user's default size |
| Line height | Unitless (`1.5`) | Scales with each element's own font size. A `rem` or `px` line height does not follow per-element sizes, and an `em` line height is inherited as a fixed computed value, so child text with a larger size gets cramped lines |
| Padding around text | `rem`, or `em` in components that come in sizes | Breathing room grows with the words |
...

From dembrandt's repository, MIT licence.

Related skills

  • Checked

    Port code to Rust

    Ports C, C++, Python, Go or JavaScript code into idiomatic Rust, with tests that prove it behaves the same.

    by morganlinton 2.2k
    8/101 credit
  • Checked

    ComfyUI custom node UI

    Adds widgets, sidebar tabs, commands and dialogs to ComfyUI custom nodes, so your node feels built in.

    by jtydhr88 325
    7/101 credit
  • Checked

    Scrolling menu upgrade

    Finds outdated react-horizontal-scrolling-menu code and rewrites it for version 8 so the menu works again.

    by asmyshlyaev177 789
    7/101 credit
  • Checked

    Scroll Menu Testing and SSR

    Gets react-horizontal-scrolling-menu working in Next.js and tested in Jest and Playwright without flicker.

    by asmyshlyaev177 789
    7/101 credit
  • Checked

    Conform React Forms

    Builds React forms with Conform and Zod that validate on the server and still work before JavaScript loads.

    by TerminalSkills 221
    7/101 credit
  • Checked

    Next.js 16 App Builder

    Builds Next.js 16 apps the current way, with Server Components, Server Actions, caching and the new proxy file.

    by TerminalSkills 221
    7/101 credit

Secure checkout

Credits

AUD

  1. 1Choose
  2. 2Pay on Square
  3. 3Credits added