tab-size
CSS property is used to customize the width of tab characters (U+0009).
/* <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;
<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.
| 初始值 |
8
|
|---|---|
| 适用于 | block containers |
| 继承 | yes |
| 计算值 | the specified integer or an absolute length |
| 动画类型 | a length |
<integer> | <length>
pre {
tab-size: 4; /* Set tab size to 4 characters wide */
}
pre {
tab-size: 0; /* Remove indentation */
}
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.
<p>no tab</p> <p> default tab size of 8 characters wide</p> <p class="custom"> custom tab size of 3 characters wide</p> <p> 3 spaces, equivalent to the custom tab size</p>
p {
white-space: pre;
}
.custom {
tab-size: 3;
-moz-tab-size: 3;
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Text Module Level 3
The definition of 'tab-size' in that specification. |
工作草案 | 初始定义 |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
tab-size
|
Chrome
完整支持
21
注意事项
|
Edge
完整支持
79
注意事项
|
Firefox
完整支持
4
Prefixed
注意事项
|
IE 不支持 No |
Opera
完整支持
15
|
Safari 完整支持 6.1 | WebView Android 完整支持 4.4 |
Chrome Android
完整支持
25
注意事项
|
Firefox Android
完整支持
4
Prefixed
注意事项
|
Opera Android
完整支持
14
|
Safari iOS 完整支持 7 |
Samsung Internet Android
完整支持
1.5
注意事项
|
<length>
|
Chrome 完整支持 42 | Edge 完整支持 79 | Firefox 完整支持 53 | IE 不支持 No | Opera 完整支持 29 | Safari 不支持 No | WebView Android 完整支持 56 | Chrome Android 完整支持 42 | Firefox Android 完整支持 53 | Opera Android 完整支持 29 | Safari iOS 不支持 No | Samsung Internet Android 完整支持 4.0 |
完整支持
不支持
见实现注意事项。
要求使用供应商前缀或不同名称。