files/en-us/web/css/reference/properties/text-spacing-trim/index.md
{{seecompattable}}
The text-spacing-trim CSS property controls the internal spacing set on Chinese/Japanese/Korean (CJK) punctuation characters between adjacent characters (kerning) and at the start or end of text lines.
/* Keyword values */
text-spacing-trim: normal;
text-spacing-trim: space-all;
text-spacing-trim: space-first;
text-spacing-trim: trim-start;
/* Global values */
text-spacing-trim: inherit;
text-spacing-trim: initial;
text-spacing-trim: revert;
text-spacing-trim: revert-layer;
text-spacing-trim: unset;
<spacing-trim>
: Defines the different spacing trim options. Available values are:
normal
space-all
space-first
normal, except that CJK full-width opening punctuation characters are set to be full-width at the start of the first line of the text's block container, and the start of every subsequent line coming after an explicit line break such as a newline character.trim-start
normal, except that CJK full-width opening punctuation characters are set to be half-width at the start of each line.[!NOTE] The CSS Text module also defines
trim-both,trim-all, andautovalues. However, these are not currently implemented in any browser.
The text-spacing-trim property applies spacing/kerning to CJK punctuation characters to produce visually pleasing typography as defined by the Requirements for Japanese text layout (JLREQ) and the Requirements for Chinese text layout (CLREQ).
Many CJK punctuation characters include glyph-internal spacing. For example, the CJK full stop and the CJK close parenthesis usually have glyph-internal spacing on their right-hand side, to give them a constant advance measure consistent with other ideographic characters. However, when they appear in a row, the glyph-internal spacing can become excessive.
text-spacing-trim can be used to adjust such excessive spacing between adjacent characters (kerning) and at the start or end of text lines. Generally speaking:
[!NOTE] To avoid the risk of excessive kerning, fonts must have the OpenType Alternate Half Widths (
halt) feature, the Contextual Half-width Spacing (chws) feature, or both. If the font doesn't have either feature,text-spacing-trimis disabled.
When pairs of punctuation characters are adjacent to one another, the space between them is collapsed according to the following rules:
{{CSSInfo}}
{{CSSSyntax}}
text-spacing-trim value comparisonThis example compares the effect of four different text-spacing-trim properties, applying them to four identical paragraphs so you can see the visual differences between each one.
<main>
<div id="normal">
<h2>normal</h2>
<p>
(東)、【「(東)」】。
「東」「東」「東」東東東「東」。
</p>
</div>
<div id="space-all">
<h2>space-all</h2>
<p>
(東)、【「(東)」】。
「東」「東」「東」東東東「東」。
</p>
</div>
<div id="space-first">
<h2>space-first</h2>
<p>
(東)、【「(東)」】。
「東」「東」「東」東東東「東」。
</p>
</div>
<div id="trim-start">
<h2>trim-start</h2>
<p>
(東)、【「(東)」】。
「東」「東」「東」東東東「東」。
</p>
</div>
</main>
main {
font-family:
"Yu Gothic", "YuGothic", "Noto Sans JP", "Hiragino Sans",
"Hiragino Kaku Gothic ProN", sans-serif;
display: grid;
gap: 0.5em;
grid-template-columns: 1fr 1fr;
width: 70%;
margin: 0 auto;
}
h2 {
font-size: 80%;
margin: 0;
}
p {
font-size: 20px;
border: 1px solid blue;
margin: 0;
}
#normal {
text-spacing-trim: normal;
grid-column: 1;
grid-row: 1;
}
#space-all {
text-spacing-trim: space-all;
grid-column: 2;
grid-row: 1;
}
#space-first {
text-spacing-trim: space-first;
grid-column: 1;
grid-row: 2;
}
#trim-start {
text-spacing-trim: trim-start;
grid-column: 2;
grid-row: 2;
}
{{EmbedLiveSample("text-spacing-trim value comparison", "100%",320)}}
{{Specifications}}
{{Compat}}