cqh
One percent of the nearest query container's height.
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 1cqh = 1/100 of the nearest container's height
How it works
1cqh is a hundredth of the nearest query container’s height, and it asks more of the container than cqw does. The height must be known without looking at the children, which needs container-type: size. That setting makes the container’s size independent of its content, so a container with no explicit height collapses to zero and cqh is zero too.
With only container-type: inline-size there is no height to measure. The unit still resolves, to the small viewport height, so 10cqh in such a container is 10svh. A card that sets inline-size and uses cqh inside it ends up sized by the window without saying so.
In practice cqh suits fixed-height widgets such as a dashboard tile, a carousel frame or a chart panel, where the author sets the height. For text blocks that grow with content, use cqw or cqi.
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
- Stays put under
- the reader's text size
- the window size
- the font in use
- phone toolbars
- the writing mode
Reach for it when
Fixed-height widgets such as dashboard tiles and chart panels.
Watch out
container-type: size is the only setting that lets the height be queried, and it also cuts the box off from its children's height. Give the container a block-size, or it measures 0px and so does everything in cqh.
Before
.panel {
container-type: size;
}
.panel .chart {
block-size: 80cqh;
}After
.panel {
container-type: size;
block-size: 20rem;
}
.panel .chart {
block-size: 80cqh;
}