The word-spacing CSS property sets the length of space between words and between tags.
Syntax
/* Keyword value */ word-spacing: normal; /* <length> values */ word-spacing: 3px; word-spacing: 0.3em; /* Global values */ word-spacing: inherit; word-spacing: initial; word-spacing: revert; word-spacing: revert-layer; word-spacing: unset;
Values
normal-
The normal inter-word spacing, as defined by the current font and/or the browser.
length-
Specifies extra spacing in addition to the intrinsic inter-word spacing defined by the font.
Examples
HTML
<div id="mozdiv1">Lorem ipsum dolor sit amet.</div> <div id="mozdiv2">Lorem ipsum dolor sit amet.</div>
CSS
#mozdiv1 {
word-spacing: 15px;
}
#mozdiv2 {
word-spacing: 5em;
}
Accessibility concerns
A large positive or negative word-spacing value will make the sentences the styling is applied to unreadable. For text styled with a very large positive value, the words will be so far apart that it will no longer appear to be a sentence. For text styled with a large negative value, the words will overlap each other to the point where the beginning and end of each word is unrecognizable.
Legible word-spacing must be determined on a case-by-case basis, as different font families have different character widths. There is no one value that can ensure all font families automatically maintain their legibility.
- MDN Understanding WCAG, Guideline 1.4 explanations
- Understanding Success Criterion 1.4.8 | W3C Understanding WCAG 2.0
Formal definition
| Initial value | normal |
|---|---|
| Applies to | text |
| Inherited | yes |
| Computed value | an absolute length and/or a percentage |
| Animation type | by computed value type |
Formal syntax
normal | <length-percentage>