Skip to content
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4572884
created the text-autospace page
dletorey Aug 19, 2025
4e9a8b8
Merge branch 'main' into 40776-text-autospace
dletorey Aug 26, 2025
791a055
added text-autospace to css text page
dletorey Aug 27, 2025
ae753b6
added text-autospace to see also of text-spacing-trim
dletorey Aug 27, 2025
8181ac8
updated see also and added values
dletorey Aug 27, 2025
275a7c7
added values definitions and example
dletorey Aug 27, 2025
1ff66ec
Merge branch 'main' into 40776-text-autospace
dletorey Aug 27, 2025
725962f
Update files/en-us/web/css/text-autospace/index.md
dletorey Aug 27, 2025
66f32dc
Update files/en-us/web/css/text-autospace/index.md
dletorey Aug 27, 2025
b1ad5c5
Update files/en-us/web/css/text-autospace/index.md
dletorey Aug 27, 2025
0135386
Update files/en-us/web/css/text-autospace/index.md
dletorey Aug 27, 2025
7a57ecc
Update files/en-us/web/css/text-spacing-trim/index.md
dletorey Sep 1, 2025
5c81802
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
ff88bc3
Merge branch 'main' into 40776-text-autospace
dletorey Sep 1, 2025
18bd0be
removed experimental inline macro
dletorey Sep 1, 2025
4256784
added <autospace> and reordered autospace values
dletorey Sep 1, 2025
aecea23
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
0bb2d94
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
e26fc1f
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
4cfb30b
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
c3e08cf
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
462126d
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
ba2b64d
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
8525211
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
4420187
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 1, 2025
c176770
Merge branch '40776-text-autospace' of github.com:dletorey/content in…
dletorey Sep 1, 2025
c4c3a29
updated the html code block
dletorey Sep 1, 2025
d3af24f
reordered syntax to match the spec and added extra syntax options for…
dletorey Sep 1, 2025
0beee61
added note about insert
dletorey Sep 1, 2025
64103db
Merge branch 'main' into 40776-text-autospace
dletorey Sep 1, 2025
dbceebd
Merge branch 'main' into 40776-text-autospace
dletorey Sep 2, 2025
876c31a
updated the description of no-autospace value
dletorey Sep 2, 2025
c3ba46e
Merge branch '40776-text-autospace' of github.com:dletorey/content in…
dletorey Sep 2, 2025
39066ed
Update files/en-us/web/css/text-autospace/index.md
dletorey Sep 3, 2025
9f57164
Merge branch 'main' into 40776-text-autospace
dletorey Sep 8, 2025
d1da269
added indentation for values and corrected the syntax examples
dletorey Sep 8, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions files/en-us/web/css/css_text/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The **CSS text** module defines how to perform text manipulation, like line brea
- {{cssxref("text-align-last")}}
- {{cssxref("text-indent")}}
- {{cssxref("text-justify")}}
- {{cssxref("text-autospace")}}
- {{cssxref("text-spacing-trim")}} {{Experimental_Inline}}
- {{cssxref("text-transform")}}
- {{cssxref("text-wrap")}}
Expand Down
182 changes: 182 additions & 0 deletions files/en-us/web/css/text-autospace/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
---
title: text-autospace
slug: Web/CSS/text-autospace
page-type: css-property
browser-compat: css.properties.text-autospace
sidebar: cssref
---

The **`text-autospace`** [CSS](/en-US/docs/Web/CSS) property allows you to specify the space applied between Chinese/Japanese/Korean (CJK) and non-CJK characters.

## Syntax

```css
text-autospace: normal;
text-autospace: no-autospace;
text-autospace: ideograph-alpha;
text-autospace: ideograph-numeric;
text-autospace: punctuation;
text-autospace: insert;
text-autospace: replace;
text-autospace: ideograph-alpha insert;
text-autospace: ideograph-alpha replace;
text-autospace: ideograph-numeric insert;
text-autospace: ideograph-numeric replace;
text-autospace: punctuation insert;
text-autospace: punctuation replace;
Comment thread
dletorey marked this conversation as resolved.
Outdated
text-autospace: auto;
Comment thread
dletorey marked this conversation as resolved.

/* Global values */
text-autospace: inherit;
text-autospace: initial;
text-autospace: revert;
text-autospace: revert-layer;
text-autospace: unset;
```

### Values
Comment thread
dletorey marked this conversation as resolved.

- `normal`
- : Creates the default behavior to automatically apply spacing between CJK and non-CJK characters and around punctuation. This value has the same effect as applying both [`ideograph-alpha`](#ideograph-alpha) and [`ideograph-numeric`](#ideograph-numeric).
- `<autospace>`
- : Provides more control over spacing behaviors. It accepts:
- the keyword `no-autospace`, or
- a combination of one or more of `ideograph-alpha`, `ideograph-numeric`, and `punctuation`, optionally followed by `insert` or `replace`.
- `no-autospace`
Comment thread
dletorey marked this conversation as resolved.
Outdated
- : Disables automatic spacing between CJK and non-CJK characters.
- `ideograph-alpha`
- : Adds spacing only between ideographic characters (such as Katakana and Han) and non-ideographic letters (such as Latin). It does not add spacing between ideographic characters and non-ideographic numbers.
- `ideograph-numeric`
- : Adds spacing only between ideographic characters (such as Katakana and Han) and non-ideographic numbers (such as Latin). It does not add spacing between ideographic characters and non-ideographic letters.
- `punctuation`
- : Creates extra non-breaking spacing around punctuation as required by language-specific typographic conventions.
Comment thread
dletorey marked this conversation as resolved.
Outdated
- `insert`
- : If there are no spaces between the _ideograph_ and _non-ideographic_ scripts the user agent automatically inserts the correct spacing.
- `replace`
- : If there are spaces between the _ideograph_ and _non-ideographic_ scripts, such as [U+0020](/en-US/docs/Glossary/Whitespace), the user agent automatically replaces it with the correct spacing.
Comment thread
dletorey marked this conversation as resolved.
Outdated
- `auto`
- : Lets the browser choose typographically appropriate spacing. The spacing may vary across browsers and platforms.

> [!NOTE]
> If neither `insert` nor `replace` are specified, the behavior is the same as `insert`.

> [!NOTE]
> This property is additive with the {{CSSXRef("word-spacing")}} and {{CSSXRef("letter-spacing")}} properties. The amount of spacing contributed by the `letter-spacing` setting is added to the spacing created by `text-autospace`. The same applies to `word-spacing`.

## Formal definition

{{CSSInfo}}

## Formal syntax

{{csssyntax}}

## Examples

This example shows the difference between various values of `text-autospace`. Try selecting a value from the drop-down box to see how it affects the spacing in the text.

```html hidden
<form>
<label for="autospace">Choose value for <code>text-autospace:</code></label>
<select name="autospace" id="autospace">
<option selected value="no-autospace">no-autospace</option>
<option value="normal">normal</option>
<option value="ideograph-alpha">ideograph-alpha</option>
<option value="ideograph-numeric">ideograph-numeric</option>
</select>
</form>
<div class="unsupported">
<code>text-autospace</code> is not supported in your browser.
</div>
```

```html
<main>
<figure class="no-autospace">
<figcaption>
<code>
text-autospace: <span id="autospace-value">no-autospace</span>;
</code>
</figcaption>
<div>
<p>HTML超文本标记语言</p>
<p>42四十二</p>
</div>
</figure>
</main>
```

```css
.no-autospace {
text-autospace: no-autospace;
}
.auto {
text-autospace: auto;
}
.normal {
text-autospace: normal;
}
.ideograph-alpha {
text-autospace: ideograph-alpha;
}
.ideograph-numeric {
text-autospace: ideograph-numeric;
}
```

```css hidden
figure {
margin: 1rem;
div {
font-size: 2rem;
padding: 1rem;
font-family: sans-serif;
border: tomato solid 1px;
}
p {
margin: 0;
}
}
main {
max-width: max-content;
}
@supports not (text-autospace: normal) {
form {
display: none;
}
.unsupported {
color: red;
}
}
@supports (text-autospace: normal) {
.unsupported {
display: none;
}
}
```

```js hidden
const chose = document.querySelector("#autospace");
const fig = document.querySelector("figure");
const codeValue = document.querySelector("#autospace-value");
chose.addEventListener("change", (e) => {
fig.className = e.target.value;
codeValue.innerText = e.target.value;
});
```

{{EmbedLiveSample("Example", 200, 200)}}

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- {{cssxref('text-spacing-trim')}}
- [`ic`](/en-US/docs/Web/CSS/CSS_Values_and_Units/Numeric_data_types#local_font-relative_lengths) and [`ric`](/en-US/docs/Web/CSS/CSS_Values_and_Units/Numeric_data_types#root_font-relative_lengths) units
- [CSS Text](/en-US/docs/Web/CSS/CSS_text) module
3 changes: 2 additions & 1 deletion files/en-us/web/css/text-spacing-trim/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,6 @@ p {

## See also

- {{CSSXref("text-autospace")}}
- [`ic`](/en-US/docs/Web/CSS/CSS_Values_and_Units/Numeric_data_types#local_font-relative_lengths) and [`ric`](/en-US/docs/Web/CSS/CSS_Values_and_Units/Numeric_data_types#root_font-relative_lengths) units
- [CSS Text](/en-US/docs/Web/CSS/CSS_text) module
- [CSS text](/en-US/docs/Web/CSS/CSS_text) module