The tab-size property sets the rendered width of each tab character (U+0009). A number means that many space widths. A length such as 2em sets an absolute width.
It is most useful on <pre> and code samples where tabs are preserved. Pair it with white-space: pre, pre-wrap, or break-spaces. The property is inherited. The initial value is 8.
Baseline · Widely available.
Not deprecated. Older Firefox used the prefix -moz-tab-size; modern browsers use unprefixed tab-size.
Syntax
CSS Syntax
syntax.css
tab-size:<number> | <length>;
Example: tab-size: 4; or tab-size: 2em;. Values must be non-negative.
No indent. Tabs still exist in the text, but they take no horizontal space.
Compare with 4. Switch to Try It Yourself and change 0 to 4 to see the difference.
Rare in UI. Most code samples use 2 or 4, not 0.
Edge Cases & Pitfalls
If tabs look unchanged, one of these is usually why.
spaces
Only real tabs count
tab-size ignores indentation made with space characters. The content must contain U+0009 tabs.
ws
Needs preserved whitespace
With default white-space: normal, tabs collapse. Use pre, pre-wrap, or break-spaces.
html
Editors may convert tabs to spaces
Many editors insert spaces on Tab. Check that the file actually stores tab characters.
neg
Negative values are invalid
Only non-negative numbers and lengths are allowed. Invalid values are ignored.
prefix
Old -moz-tab-size
Unprefixed tab-size is enough for modern browsers. Keep the prefix only if you must support very old Firefox.
Compatibility
Browser Support
tab-size is a browser CSS property for rendering tab characters. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
tab-size
Chrome 42+, Edge 79+, Firefox 91+, Safari 13.1+ / iOS 13.4+. Not supported in Internet Explorer.
97%Global support
Google Chrome42+
Full support
Mozilla Firefox91+
Full support
Apple Safari13.1+
Full support
Microsoft Edge79+
Full support
Opera29+
Full support
Samsung Internet4+
Full support
Internet ExplorerNo support
No support
tab-sizeWidely supported
Bottom line: Safe for modern sites. Prefer unprefixed tab-size. This is not a JavaScript runtime API.
Remember
Key Takeaways
Role: set how wide each tab character renders — number of spaces or a length.
Initial:8. Common code values are 2 and 4.
Needs tabs + pre whitespace. Spaces alone and white-space: normal hide the effect.
Inherited. Set once on a code container to style nested lines.
One line:tab-size controls tab width in preformatted text — not regular space indentation.
Frequently Asked Questions
It sets how wide each tab character (U+0009) is rendered. A number means that many space widths. A length such as 2em sets an absolute tab width.
The initial value is 8, so each tab is as wide as eight space characters unless you change it.
When tab characters are preserved — typically in a pre element, or with white-space: pre, pre-wrap, or break-spaces. With the default white-space: normal, tabs collapse and you will not see the effect.
No. It only affects real tab characters in the text. Indentation made with space characters is unchanged.
Yes. tab-size: 0 is valid and makes tabs take no width.
It is Baseline Widely available: Chrome 42+, Edge 79+, Firefox 91+, Safari 13.1+. It is a browser CSS property, not a Node.js feature. Internet Explorer does not support it.