You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!
This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The tab-size
CSS property is used to customize the width of a tab (U+0009
) character.
/* <integer> values */ tab-size: 4; tab-size: 0; /* <length> values */ tab-size: 10px; tab-size: 2em; /* Global values */ tab-size: inherit; tab-size: initial; tab-size: unset;
Initial value | 8 |
---|---|
Applies to | block containers |
Inherited | yes |
Media | visual |
Computed value | the specified integer or an absolute length |
Animation type | a length |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
Values
<integer>
- The number of spaces in a tab. Must be nonnegative.
<length>
- The width of a tab. Must be nonnegative.
Formal syntax
<integer> | <length>
Examples
pre { tab-size: 4; /* Set tab size to 4 spaces */ }
pre { tab-size: 0; /* Remove indentation */ }
pre { tab-size: 2; /* Set tab size to 2 spaces */ }
Live sample
This example compares a default tab size with a custom tab size. Note that white-space
is set to pre
to prevent the tabs from collapsing.
HTML
<p>no tab</p> <p>	default tab size of 8 spaces</p> <p class="custom">	custom tab size of 3 spaces</p> <p> 3 spaces, equivalent to the custom tab size</p>
CSS
p { white-space: pre; } .custom { -moz-tab-size: 3; tab-size: 3; }
Result
Specifications
Specification | Status | Comment |
---|---|---|
CSS Text Module Level 3 The definition of 'tab-size' in that specification. |
Working Draft | Initial definition |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
tab-size | Chrome
Full support
21
| Edge No support No | Firefox
Full support
4
| IE No support No | Opera
Full support
15
| Safari Full support 6.1 | WebView Android Full support 4.4 | Chrome Android
Full support
25
| Firefox Android
Full support
4
| Opera Android
Full support
14
| Safari iOS Full support 7 | Samsung Internet Android ? |
<length> | Chrome Full support 42 | Edge No support No | Firefox Full support 53 | IE No support No | Opera Full support 29 | Safari No support No | WebView Android Full support 56 | Chrome Android Full support 42 | Firefox Android Full support 53 | Opera Android Full support 29 | Safari iOS No support No | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- See implementation notes.
- See implementation notes.
- Requires a vendor prefix or different name for use.
- Requires a vendor prefix or different name for use.
See also
- Controlling size of a tab character (U+0009), an email by Anne van Kesteren to the CSSWG.