W3cubDocs

/CSS

tab-size

The tab-size CSS property is used to customize the width of tab characters (U+0009).

Syntax

/* <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;

Values

<integer>
A multiple of the advance width of the space character (U+0020) to be used as the width of tabs. Must be nonnegative.
<length>
The width of tabs. Must be nonnegative.

Formal definition

Initial value 8
Applies to block containers
Inherited yes
Computed value the specified integer or an absolute length
Animation type a length

Formal syntax

<integer> | <length>

Examples

Expanding by character count

pre {
  tab-size: 4; /* Set tab size to 4 characters wide */
}

Collapse tabs

pre {
  tab-size: 0; /* Remove indentation */
}

Comparing to the default size

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>&#0009;default tab size of 8 characters wide</p>
<p class="custom">&#0009;custom tab size of 3 characters wide</p>
<p>&nbsp;&nbsp;&nbsp;3 spaces, equivalent to the custom tab size</p>

CSS

p {
  white-space: pre;
}

.custom {
  tab-size: 3;
  -moz-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 compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
tab-size 21
21
This property is not yet animatable.
79
79
This property is not yet animatable.
4
Prefixed
4
Prefixed
Prefixed Implemented with the vendor prefix: -moz-
See bug 737785 for the status of unprefixing this property.
Before Firefox 53, this property was not animatable.
No 15
15
10.5
Prefixed
Prefixed Implemented with the vendor prefix: -o-
6.1
<length> 42 79 53 No 29 No
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
tab-size 4.4 25
25
This property is not yet animatable.
4
Prefixed
4
Prefixed
Prefixed Implemented with the vendor prefix: -moz-
See bug 737785 for the status of unprefixing this property.
Before Firefox 53, this property was not animatable.
14
14
11
Prefixed
Prefixed Implemented with the vendor prefix: -o-
7 1.5
1.5
This property is not yet animatable.
<length> 56 42 53 29 No 4.0

See also

© 2005–2020 Mozilla and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/tab-size