Definition and Usage
The word-spacing property specifies the spacing between words in text or the spacing between inline elements within a specific element.
Positive values increase the word spacing, while negative values decrease the word spacing.
See It In Action With A CSS Demo
Adjusting Spacing Between Words
Increases or decreases the spacing between words in text within a specific element.
<p>This text shows the spacing between words.</p>
p {
word-spacing: /* value */
}
This text shows the spacing between words.
Adjusting Spacing Between Inline Elements
An inline element is an element that is placed inside another element in an HTML document and is displayed continuously on a single line without line breaks like text.
When inline elements within a specific element are written with line breaks in the editor, a space is created between them, just like a single space in text.
It increases or decreases the spacing between these inline elements.
<div>
<button>Inline Element</button>
<button>Inline Element</button> <!-- A space is created when this element is
placed on a new line. -->
</div>
div {
word-spacing: /* value */
}
The syntax for the word-spacing property is as follows.
Formal Syntax
selector {
word-spacing: /* value */
}
Formal Definition
| Initial value | normal |
|---|---|
| Applies to | all elements |
| Inherited | yes |
| Animatable | yes |
Values
normal |
The normal spacing for the current font.
Calculated as 0 in length units. |
|---|---|
length |
A length value. (Positive, 0, and negative values are allowed.) |
percentage |
A percentage (%) value relative to the font size of the applied text.
Supported only in some browsers. See Browser Compatibility. |
Syntax
/* Keyword value */
word-spacing: normal;
/* <length> values */
word-spacing: 0; /* Same as normal */
word-spacing: 2px;
word-spacing: -2px;
word-spacing: 1em;
word-spacing: -0.15em;
word-spacing: 1rem;
word-spacing: -0.11rem;
/* Percentage (%) values: Supported only in some browsers */
word-spacing: -50%;
word-spacing: 200%;
/* Global values */
word-spacing: inherit;
word-spacing: initial;
word-spacing: revert;
word-spacing: revert-layer;
word-spacing: unset;
Accessibility Considerations
If the spacing between words is set too narrow or too wide using the word-spacing property, users may have difficulty reading text with this style applied.
If the spacing between words is set too narrow or too wide, users may have difficulty reading text with this style applied.
If the spacing between words is set too narrow or too wide, users may have difficulty reading text with this style applied.
Browser Compatibility
Last updated:
| Property and Value |
Desktop Chrome
|
Desktop Edge
|
Desktop Firefox
|
Safari
|
|---|---|---|---|---|
word-spacing
|
1 | 12 | 1 | 1 |
percentage values |
145 | 145 | 45 | 7 |
The percentage value is not supported in Samsung Internet and Opera Mobile.
Specifications
| Specification | |
|---|---|
word-spacing
|
CSS Text Module Level 4 #word-spacing-property |
References
See Also
- CSS word-break Property – Rules for Breaking Words When Text Wraps
- CSS letter-spacing Property – Specifies Letter Spacing
- CSS font-kerning Property – A Complete Guide
- CSS text-overflow Property – Specifying a Single-Line Text Ellipsis (…)
- CSS -webkit-line-clamp Property – Setting a Multi-Line Text Ellipsis (…)
- CSS text-align Property – Setting Horizontal Alignment for Text and Inline Content
- CSS writing-mode Property – Setting Text in Vertical Writing Mode
- CSS white-space Property – Specifies White Space and Soft Wrapping