tab-size
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2021.
Die tab-size
CSS-Eigenschaft wird verwendet, um die Breite von Tabulatorzeichen (U+0009) anzupassen.
Probieren Sie es aus
tab-size: 10px;
tab-size: 16px;
tab-size: 24px;
tab-size: 4;
123
#example-element {
border: 1px solid;
}
Syntax
css
/* values */
tab-size: 4;
tab-size: 0;
/* values */
tab-size: 10px;
tab-size: 2em;
/* Global values */
tab-size: inherit;
tab-size: initial;
tab-size: revert;
tab-size: revert-layer;
tab-size: unset;
Werte
Formale Definition
Anfangswert | 8 |
---|---|
Anwendbar auf | Blockcontainer |
Vererbt | Ja |
Berechneter Wert | die angegebene Ganzzahl oder eine absolute Länge |
Animationstyp | Längenangabe |
Formale Syntax
tab-size =
|
Beispiele
Erweiterung nach Zeichenanzahl
css
pre {
tab-size: 4; /* Set tab size to 4 characters wide */
}
Tabs reduzieren
css
pre {
tab-size: 0; /* Remove indentation */
}
Standard-Tabgröße vs. benutzerdefinierte Größen
Dieses Beispiel vergleicht eine Standard-Tabgröße mit einer benutzerdefinierten Tabgröße. Beachten Sie, dass white-space
auf pre
gesetzt ist, um zu verhindern, dass die Tabs zusammenfallen.
HTML
html
no tab
default tab size of 8 characters wide
custom tab size of 3 characters wide
3 spaces, equivalent to the custom tab size
custom tab size of 50px wide
CSS
css
p {
white-space: pre;
}
.custom-number {
tab-size: 3;
}
.custom-length {
tab-size: 50px;
}
Ergebnis
Spezifikationen
Specification |
---|
CSS Text Module Level 3 # tab-size-property |