Multi-column text in CSS
Newspaper columns, where the browser does the balancing.
.notes {
columns: 3 18rem;
column-gap: 2rem;
column-rule: 1px solid #e5e7eb;
column-fill: balance;
}
.notes h2 {
column-span: all;
margin-block: 1.5rem 0.5rem;
}
.notes .card {
break-inside: avoid;
margin-block-end: 1rem;
}
How it works
columnsis the shorthand for a count and an ideal width.column-fill: balanceevens the columns out; the default is to fill.break-inside: avoidkeeps a card from being split across a column.
Keywords and builtins used here
cardcolumnsnotespxrem
The run, in numbers
- Lines
- 16
- Characters to type
- 225
- Tokens
- 57
- Three-star pace
- 85 tpm
At the three-star pace of 85 tokens a minute, this run takes about 40 seconds.
Step 3 of 3 in Sizing, step 16 of 24 in Flexbox & grid.