CSS tab-size Property
Description
The tab-size
CSS property is used to control the width of tab characters within an element's content. It allows web developers to specify the number of space characters that a tab character should occupy when displayed in the browser. This property is particularly useful for maintaining consistent and readable code formatting, as it helps ensure that code and text are aligned properly when tabs are used. By setting the tab-size property, developers can ensure that tab characters are visually consistent across different platforms and devices, making it easier to manage code indentation and improve code readability.
- Initial value
- 8
- Applies to
- block containers
- Inherited
- Yes
- Computed value
- the specified integer or an absolute length
- Animatable
- a length
- JavaScript syntax
- object.style.tabSize
Interactive Demo
Tab Size Demo
Syntax
tab-size: <integer> | <length>
Values
- <integer>The number of spaces in a tab. Must be positive value.
- <length>The width of a tab. Must be positive value.
Example
<pre>
<div class="test">Tabs	for	example	are	located	between	words</div>
<div class="test2">Tabs	for	example	are	located	between	words</div>
<div class="test3">Tabs	for	example	are	located	between	words</div>
<div class="test4">Tabs	for	example	are	located	between	words</div>
<div class="test5">Tabs	for	example	are	located	between	words</div>
</pre>
div {
border: 1px solid blue;
background: azure;
}
.test {
-moz-tab-size: 8;
tab-size: 8;
}
.test2 {
-moz-tab-size: 12;
tab-size: 12;
}
.test3 {
-moz-tab-size: 16; * to support Firefox * /
tab-size: 16;
}
.test4 {
-moz-tab-size: 7em;
tab-size: 7em;
}
.test5 {
-moz-tab-size: 40px;
tab-size: 40px;
}
Browser Support
The following table will show you the current browser support for the CSS tab-size
property.
Desktop | |||||
79 | 21 | 91 | 15 | 7 |
Tablets / Mobile | |||||
25 | 91 | 14 | 7 | 1.5 | 4.4 |
Last updated by CSSPortal on: 2nd January 2024