CSS

css/no-fixed-height-text

Boxes that hold text do not combine a fixed height with hidden overflow; use min-height so enlarged or spaced text is not clipped.

seriousstaticWCAG 1.4.4, 1.4.12 · AAfe-css-layout

Why

A box of height: 72px; overflow: hidden fits the text only at the designer's font size, line height and language. When someone enlarges text, raises line or letter spacing, or the copy is translated into a longer language, the end of the text is cut off without a trace.

Fix

Use min-height (or min-block-size) and padding, and let the content decide the height. To shorten long text on purpose, use line-clamp with a way to read the rest. Fixed sizes are fine for media and for boxes whose width is fixed too (avatars, icon buttons). Check by applying the WCAG text-spacing values (line height 1.5, letter spacing 0.12em, word spacing 0.16em, paragraph spacing 2em).

Examples

/* bad */
.card__excerpt { height: 72px; overflow: hidden; }
/* good */
.card__excerpt { min-height: 4.5rem; }

Sources

Facts

Id
css/no-fixed-height-text
Severity
serious
Check
static checked in the source by audit
Applies to
css scss less html vue svelte astro
WCAG 2.2
1.4.4, 1.4.12, level AA
Taught by the skill
fe-css-layout CSS layout
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain css/no-fixed-height-text