CSS propertyTypography
word-spacing
Changes the spacing between words.
- Initial value
normal- Inherited
- Yes
- Animatable
- yes, as a length
- Applies to
- all elements
- JavaScript
element.style.wordSpacing = "0.3em"
Example
#CSS
.slogan {
text-transform: uppercase;
letter-spacing: 0.1em;
word-spacing: 0.4em;
}Example HTML
<p class="slogan" style="text-transform: uppercase; letter-spacing: 0.1em; word-spacing: 0.4em; margin: 0;">Learn by playing</p>Preview
Definition and usage
#The word-spacing property adds extra space to every gap between words. A negative value pulls the words closer together.
It’s useful less often than letter-spacing, but it can help with fonts that have a very narrow or very wide space character, and in decorative lettering.
With justified text, the browser already adjusts the spacing between words, and word-spacing is added on top of those calculated values.
Syntax
#Syntax
word-spacing: normal | <length>;Values
#Values in practice
#normal
The font’s regular space character.
.demo { word-spacing: normal; }0.5em
Noticeably wider spacing between words.
.demo { word-spacing: 0.5em; }-2px
Words closer together.
.demo { word-spacing: -2px; }Browser support
#Widely available
Works in all modern browsers, phones included. You can use it without worry.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- When you spread out letters with
letter-spacing, increaseword-spacingtoo, so words still stand apart clearly. - Don’t use
word-spacingfor layout spacing, that’s what margins andgapare for.
Related entries
#Spotted a mistake or missing an example? Write to us.