Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

tab-size — spacing between tab stops

The tab-size property sets the spacing between tab stops for preserved tab characters. It accepts a nonnegative number or length and requires white-space settings that preserve tabs.

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

Syntax

tab-size: <number [0,∞]> | <length [0,∞]>;

tab-size controls the rendering of preserved tabs (U+0009). Its initial value is 8, and it is inherited. It does not change ordinary spaces or the text content.

A number, including a fraction, specifies a multiple of the space (U+0020) advance width of the nearest block container ancestor, including letter-spacing and word-spacing. A length, such as 32px, sets the interval directly. Negative values and percentages are invalid; 0 makes preserved tabs not render.

A tab advances text to the next tab stop rather than always adding a fixed number of spaces. Stops are measured from the block container’s starting content edge. If the next stop is less than 0.5ch away, the subsequent stop is used.

Use, for example, white-space: pre or white-space: pre-wrap to preserve tabs; with white-space: normal, they collapse. In the example, &#9; encodes an actual tab, and tab-size: 4 places the B characters in columns 5 and 9.

Examples

<!doctype html>
<meta charset="utf-8">
<title>tab-size</title>
<style>
  pre {
    white-space: pre;
    font: 16px monospace;
    letter-spacing: 0;
    word-spacing: 0;
    tab-size: 4;
  }
</style>
<pre>A&#9;B
AAAA&#9;B</pre>

Result

A   B
AAAA    B

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