CSS word-spacing Property

CSS word-spacing property is used to change the gap between the words of a text.

A positive value increases the gap while a negative value decreases the gap between the words. It can be specified in any valid CSS length format such as px, em, rem, cm, etc.

Try out the example below to see how it works:

Example:

.p1{
  word-spacing: normal;
}
.p2{
  word-spacing: 10px;
}
.p3{
  word-spacing: 20px;
}
.p4{
  word-spacing: -1px;
}

CSS Syntax

The word-spacing property has the below syntax:

word-spacing: normal|length|initial|inherit;

Property Values

The word-spacing property accepts the following values:

normalSets a normal spacing between the words. This is the default value.
lengthSets space between words in a CSS length format such as px, em, rem, cm, etc. Negative values are also allowed.
initialSets the word-spacing property to its default value(normal).
inheritInherits the word-spacing property from its parent element.

General Info

Default Valuenormal
InheritedYes
JavaScript Usageelement.style.wordSpacing = “20px”

Author

  • Manoj Kumar

    Hi, My name is Manoj Kumar. I am a full-stack developer with a passion for creating robust and efficient web applications. I have hands-on experience with a diverse set of technologies, including but not limited to HTML, CSS, JavaScript, TypeScript, Angular, Node.js, Express, React, and MongoDB.

    View all posts