Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

Q — quarter-millimeter

Q is an absolute CSS length unit: 1Q = 0.25mm. It has a fixed conversion to px but does not guarantee an actual physical measurement on a screen.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate; the usage example passed verification in isolated Chromium 157.0.8103.51

Syntax

<number>Q

Q means a quarter-millimeter and belongs to the <length> type. The relationships are 1Q = 0.25mm, 40Q = 1cm, and 101.6Q = 96px. Unlike relative units, it does not depend on the font size or viewport.

Write the number immediately before the unit, without a space, for example 4Q. The spellings Q and q are equivalent. When a typed <length> value is serialized without converting the unit, the unit is written as lowercase q. An unregistered custom property set to 4Q can still serialize as 4Q: its value is preserved as written rather than serialized as a typed <length> value. Resolved absolute lengths are instead serialized in px. Use this unit where a property accepts a length, subject to that property's restrictions.

“Absolute” means fixed ratios between units, not a guaranteed ruler measurement on a screen. Physical size depends on how the device maps units; one CSS pixel need not equal one device pixel.

The example sets a width of 101.6Q and displays 96px, the resolved value returned by getComputedStyle(sample).width. For this rendered element, the resolved value is the width used in layout, which happens to match the computed value here. The example checks unit conversion, not the screen's physical width.

Examples

<!doctype html>
<meta charset="utf-8">
<style>
  #sample {
    width: 101.6Q;
    height: 16px;
    padding: 0;
    border: 0;
    background: teal;
  }
</style>
<div id="sample"></div>
<pre id="result"></pre>
<script>
  const sample = document.getElementById('sample');
  document.getElementById('result').textContent =
    getComputedStyle(sample).width;
</script>

Result

96px

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