Multi-column text flow with measure constraints, column breaks, and vertical rhythm. Handles responsive column layout as a pure CSS layer — no JavaScript required.
Overview
<layout-columns> is a column flow primitive for long-form text. It controls:
- Measure — constrains line length to a readable width (
--measure-normal, 65ch by default)
- Column flow — responsive or explicit multi-column layout via CSS
columns
- Break hygiene — prevents blockquotes, figures, tables, lists from splitting across columns
- Vertical rhythm — spacing between headings, paragraphs, and blocks (same rules as
layout-text). It applies to direct children: put the headings and paragraphs straight inside, or use the attribute form on the <article> itself. Wrapping everything in one <article> child switches the rhythm off.
- Theme border reset — themes that rule under headings (brutalist, swiss) would clash with the column rules, so headings and paragraphs in the flow lose their borders. Nested components (
nav, details, cards) keep theirs.
- Inline padding — gutter so content doesn't touch screen edges on mobile
It does not set font family, hyphenation defaults, or drop caps — those belong to the <article> element's existing data-prose and data-drop-cap attributes.
Element and attribute forms
data-layout="columns" applies the same rules to any element, with the same data-layout-* modifiers. Both forms below render the same flow.
123456789101112
<layout-columns data-layout-column-count="2"> <h2>The Measure</h2> <p>…</p> <p>…</p></layout-columns> <article data-layout="columns" data-layout-column-count="2" data-prose> <h2>The Measure</h2> <p>…</p> <p>…</p></article>
Which to choose: the attribute form is the usual choice. Put data-layout="columns" and data-prose on the <article> that holds the text, so its headings and paragraphs are direct children and get the rhythm. Use <layout-columns> when there is no such element, and inside <reader-view>, which looks for the element. In the attribute form, main, article, section and aside are also container-query containers, which the element is not. See data-layout for the full comparison.
Attributes
| Attribute |
Values |
Default |
Applies to |
Description |
data-layout-column-count |
1, 2, 3, auto |
1 |
both |
Number of columns. 2 and 3 are maximums: below about 14rem per column they drop to fewer columns, down to one on a phone. auto fits as many --column-min-width (38ch) columns as the element's own width allows. |
data-layout-measure |
narrow, normal, wide |
normal |
both |
Line measure (--measure-narrow / -normal / -wide). With count 1 it caps the block. With counts 2 and 3 it caps each column, so the block is at most count × measure + gaps; without it they fill the container. With auto it sets the column width. |
data-layout-max |
narrow, normal, wide |
normal |
both |
Same as data-layout-measure (ch-based, unlike layout-center's rem-based data-layout-max). |
data-layout-align |
justify |
— |
both |
Justified text with automatic hyphenation. See the accessibility caveat. |
data-layout-centered is also accepted, because the typographic core is shared with layout-text, but it has no effect here: columns are always centered.
Custom properties
| Property |
Default |
Description |
--column-min-width |
38ch |
Minimum column width for auto mode |
--column-gap |
var(--size-2xl) |
Gap between columns |
Column strategy
The correct CSS multi-column idiom for responsive use is column-width, not column-count. The browser determines how many columns fit:
| Element width |
Auto Columns |
| 390px (phone) | ~1 column |
| 820px (tablet) | ~2 columns |
| 1200px (desktop) | ~3 columns |
The widths are the element's own width (the table assumes it fills the viewport). For explicit counts (data-layout-column-count="2" or "3"), the count is paired with a 14rem column width (columns: 14rem 2). When both are set, CSS treats the count as a maximum, so fixed counts collapse in narrow containers without a media or container query.
Spacing rules
Vertical rhythm matches layout-text and applies between direct children:
| Context |
Spacing |
| Default (between elements) | var(--size-m) |
| Before h2 | var(--size-2xl) |
| Before h3 | var(--size-xl) |
| Before h4/h5/h6 | var(--size-l) |
| After any heading | var(--size-s) |
Before/after figure, pre, table, blockquote, video, code-block, browser-window | var(--size-l) |
Examples
Single column and measure
Without any attributes, layout-columns is a single, measure-constrained column with vertical rhythm. data-layout-measure="narrow" tightens the line length for sidebars and short articles.
12345678910
<layout-columns> <h2>Article Title</h2> <p>Single-column content at --measure-normal (65ch).</p> <p>Line length stays readable at any width.</p></layout-columns> <layout-columns data-layout-measure="narrow"> <h2>Narrow Reading</h2> <p>45ch measure, for short articles, captions or sidebar content.</p></layout-columns>
Auto columns
The recommended responsive pattern. The browser fits as many columns as the element's own width allows, based on a minimum column width of 38ch. It responds to the element, not the viewport, so a columns block in a narrow sidebar on a wide screen stays single-column:
12345
<layout-columns data-layout-column-count="auto"> <h2>Responsive Columns</h2> <p>Browser determines column count from available width.</p> <p>Single column in a narrow container, more as it widens.</p></layout-columns>
Explicit two columns
Ask for a column count. The count is a maximum: when the element is too narrow for about 14rem per column it drops to fewer columns, down to one on a phone. Without a measure the block fills its container; add data-layout-measure to cap each column's line length:
12345678910
<layout-columns data-layout-column-count="2"> <h2>Two Columns</h2> <p>Two columns when there is room, one on a phone.</p></layout-columns> <layout-columns data-layout-column-count="2" data-layout-measure="narrow"> <h2>Two Narrow Columns</h2> <p>…</p></layout-columns>
Full-width breakout
A direct child with data-bleed spans every column and breaks out to the width of the nearest query container (the dashed <main> in the demo):
1234567891011
<main> <layout-columns data-layout-column-count="2"> <h1>Full-width Breakout</h1> <p>…</p> <figure data-bleed> <img src="wide.jpg" alt="…" /> <figcaption>Spans every column.</figcaption> </figure> <p>…</p> </layout-columns></main>
Inside reader-view
layout-columns is the inner surface for reader-view, which adds a paged reading mode. reader-view looks for a <layout-columns> element as its direct child (and wraps the content in one if there is none), so use the element form here. Put the headings and paragraphs directly inside it: wrapping them in one <article> would switch the vertical rhythm off, because the rhythm only spaces direct children.
12345678
<reader-view mode="pages" columns="2"> <layout-columns> <h1>Article Title</h1> <p>Content inside reader-view gets paged reading mode with column controls and page navigation.</p> <p>Each paragraph is a direct child, so the rhythm applies.</p> </layout-columns></reader-view>
Accessibility
- Justified text is a trade-off.
data-layout-align="justify" stretches word spacing to fill each line. Even with hyphenation, narrow columns develop uneven gaps and "rivers" of white space that make text harder to track for readers with dyslexia or low vision. WCAG 1.4.8 Visual Presentation (AAA) asks for text that is not justified, or a way to turn justification off. Prefer ragged-right text; justify only wide columns, and never as the only presentation of essential content.
- Long columns cost scrolling. When a multi-column block is taller than the viewport, readers scroll down one column, back up to the next, and down again. Keep column flows to short passages, use
auto so narrow screens get one column, or use <reader-view>'s paged mode for long text.
- Reading order is source order. Screen readers and keyboard focus follow the DOM, which matches the column order (top of column 1 to bottom of the last column).
- Measure adapts to the reader. The measure tokens are shortened by the dyslexia and large-text themes, and the measure is released to the full width in containers narrower than 30rem.
Best practices
- Prefer
auto over explicit counts — let the browser choose. Use explicit counts only in known-width containers.
- Pair with
data-prose — put data-layout="columns" and data-prose on the same <article>. The layout handles flow, data-prose handles typographic quality (hyphenation, limits), and the rhythm still reaches the article's children.
- Justify sparingly — ragged-right text is easier to read in narrow columns; see Accessibility.
- Don't nest inside
layout-text — use one or the other. They serve the same rhythm role.