Computer >> Computer tutorials >  >> Programming >> CSS

Managing Spacing Between Words with CSS wordspacing Property


By defining the CSS word-spacing property, we can set the amount of white space between the words.

The following examples illustrate CSS word-spacing property.

Example

<!DOCTYPE html>
<html>
<head>
<style>
div {
   margin: 2%;
   padding: 2%;
   background-color: mediumorchid;
   color: ivory;
   word-spacing: 2.2cm;
}
div:last-of-type {
   word-spacing: normal;
}
</style>
</head>
<body>
<div>I Don't Care! I Love It!</div>
<div>I Don't Care! I Love It!</div>
</body>
</html>

Output

This will produce the following result −

Managing Spacing Between Words with CSS wordspacing Property

Example

<!DOCTYPE html>
<html>
<head>
<style>
article {
   margin: 2%;
   padding: 2%;
   background-color: azure;
   word-spacing: 2.2cm;
}
article:last-of-type {
   word-spacing: normal;
}
</style>
</head>
<body>
<article>tldr; this article doesn;t mean anything</article>
<article>0123456789 is not a phone number</article>
</body>
</html>

Output

This will produce the following result −

Managing Spacing Between Words with CSS wordspacing Property