Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

cqb — container block-size unit

The cqb unit expresses a length relative to a query container’s block size, which is not always its height.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<number>cqb

1cqb is 1% of a query container’s content-box size along its block axis. In horizontal-tb, this is height; in a vertical writing mode, width. Write the number and unit without a space, for example 25cqb.

The reference is the nearest ancestor supporting size queries on the relevant axis, not the styled element itself. container-type: size enables both axes; container-type: inline-size does not enable its own block axis. Without an eligible container, the corresponding small viewport dimension is used.

An @container rule is unnecessary. container-type: size applies size containment, so do not rely on contents to size the container. The example sizes it explicitly: 25cqb yields 50px from 200px.

Examples

<!doctype html>
<meta charset="utf-8">
<title>cqb</title>
<style>
  .container {
    writing-mode: horizontal-tb;
    container-type: size;
    width: 300px;
    height: 200px;
  }
  .sample {
    width: 100px;
    height: 25cqb;
    background: teal;
  }
</style>
<div class="container">
  <div class="sample"></div>
</div>

Result

.sample: width = 100px; height = 50px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources