frontend-errors-units-rendering-viewport
Installation
SKILL.md
Frontend Errors : Units, Rendering, Viewport
This skill is the operational reference for CSS length units, viewport-percentage units, font-relative units, the CSS pixel versus device pixel distinction, and the env(safe-area-inset-*) + viewport-fit=cover pairing for notch and Dynamic Island handling. It is an errors-class skill : every section is anchored to a real-world failure mode, with the spec citation that explains it. The skill does NOT cover container-query units (cqw, cqh, cqi, cqb, cqmin, cqmax ; see [[frontend-syntax-css-container-queries]]), clamp() typography (see [[frontend-impl-typography-system]]), or animation jank (see [[frontend-errors-animation-jank]]).
Quick Reference
Floor rules
- ALWAYS use
100dvh(or100svhfor guaranteed-fit) for full-height mobile heroes. NEVER use100vh; per MDN it currently resolves to100lvh, so the hero overflows when mobile chrome is visible. - ALWAYS use
rem(or%) forfont-size. NEVER useemforfont-sizein nested contexts ; it compounds (1 5 × 1 5 × 1 5 = 3 375 at three levels deep). - ALWAYS use
emfor properties that should scale WITH the local font-size : button padding, line-height multipliers, icon sizing inside a text element. NEVER useremfor those ; the relationship to the local text breaks. - ALWAYS include
viewport-fit=coverin<meta name="viewport">AND pair every edge-touching surface withenv(safe-area-inset-*). NEVER useenv(safe-area-inset-*)alone ; withoutviewport-fit=coverthe values are 0 on iOS. - ALWAYS multiply
<canvas>backing-store width and height bydevicePixelRatioand callctx.scale(dpr, dpr). NEVER setcanvas.width = canvas.style.width; the result is blurry on Retina. - ALWAYS prefer
100%over100vwfor full-bleed sections that are children of<body>. NEVER use100vwwithout considering classic-scrollbar systems where100vwoverflows by the scrollbar width. - ALWAYS use
rem-based font sizes that respect the user's browser zoom and font-size preference. NEVER hardcodefont-size: 14px; it blocks accessibility scaling. - NEVER use
in,cm,mm,Qfor screen layouts. They are anchored to the CSS reference inch (1in = 96px), NOT to physical inches. Reserve for@media print.