cqi
One percent of the container's inline size, the direction text runs along.
Safe to useBaseline: widely available
| Browser | Since |
|---|---|
| Chrome | 105+ |
| Chrome Android | 105+ |
| Edge | 105+ |
| Firefox | 110+ |
| Firefox Android | 110+ |
| Safari | 16+ |
| Safari iOS | 16+ |
Formula 1cqi = 1/100 of the nearest container's inline size
How it works
1cqi is 1% of the container’s inline size: the width in horizontal text and the height in vertical text. It is the unit most components want, because container-type: inline-size leaves the container’s height free to follow its content, and that is enough for anything that adapts to available width.
Which axis counts depends on the writing mode of the element the unit is used on, not on the container’s. In Chromium, a child with writing-mode: horizontal-tb inside a vertical container measured cqi along the container’s width, while a vertical sibling measured along its height. The specification, read for this note, says only that each unit is evaluated on “the relevant axis described by the unit” and does not say whose writing mode decides it, so this is what Chromium does and not something the text promises. Only Chromium was tested. In a page of one writing mode the question does not come up. It matters for CJK layouts that mix directions.
Write cqi in place of cqw when the component could appear in either direction, and keep cqw when you mean the physical width. For one-language horizontal sites the two give the same number: 20cqi and 20cqw were both 80px in a container 400px wide.
Try it
A container you can resize
Drag the sliders. The box is a real query container, and the readings are 10 of each container unit measured inside it.
- Container, measured
- 300 × 140px
10cqw- 30px
10cqh- 14px
10cqi- 30px
10cqb- 14px
10cqmin- 14px
10cqmax- 30px
The same as a table
| Unit | 300 × 140px | 500 × 140px |
|---|---|---|
10cqw | 30px | 50px |
10cqh | 14px | 14px |
10cqi | 30px | 50px |
10cqb | 14px | 14px |
10cqmin | 14px | 14px |
10cqmax | 30px | 50px |
What changes it
- Moves with
- page zoom
- the query container
- the writing mode
- Stays put under
- the reader's text size
- the window size
- the font in use
- phone toolbars
Reach for it when
The default choice for component type, gaps and widths, in any writing mode.
Watch out
An element with container-type is a container for its descendants only. Its own cqi values look further up, to the next container, or to the small viewport.
Before
.card h2 {
font-size: 6vw;
}After
.card h2 {
font-size: clamp(1.5rem, 8cqi, 3rem);
}