The Wayback Machine - https://web.archive.org/web/20250308092127/https://www.geeksforgeeks.org/css-word-spacing-property/
Open In App

CSS word-spacing Property

Last Updated : 29 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

The word-spacing property adjusts the white space between words, increasing or decreasing. This CSS property can be set to normal or a specific length (positive or negative), improving readability and text formatting.

Syntax

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

Property values

Normal

  • Defines the default space between words, which is 0.25em. This is the default value.

Example: In this example we demonstrates the word-spacing CSS property, setting text to normal spacing, styled in green, bold, and a font size of 25px.

html
<!DOCTYPE html>
<html>

<head>
    <title>
        CSS word-spacing Property
    </title>
</head>

<body>
    <h1>The word-spacing Property</h1>

    <h2>word-spacing: normal:</h2>
    <p style="word-spacing: normal; 
              color: green; font-weight: 
              bold; font-size: 25px;">
        This is some text. This is some text.
    </p>
</body>

</html>

Output:

 

Length

  • It defines an additional space between words (in px, pt, cm, em, etc). Negative values are also allowed. 

Example: In this example we sets word-spacing to 20px in a paragraph, styled in green, bold, and 25px font. Demonstrates the CSS word-spacing property for text spacing adjustment.

html
<!DOCTYPE html>
<html>

<head>
    <title>CSS word-spacing Property</title>
</head>

<body>
    <h1>The word-spacing Property</h1>

    <h2>word-spacing: length is 20px</h2>
    <p style="word-spacing: 20px;
              color: green; 
              font-weight: bold;
              font-size: 25px;">
        GeeksforGeeks - A Computer Science Portal For Geeks!
    </p>
</body>

</html>

Output:

Example: In this example we demonstrating the word-spacing property with a negative value of -20px, adjusting the space between words in a paragraph for emphasis and style.

html
<!DOCTYPE html>
<html>

<head>
    <title>CSS word-spacing Property</title>
</head>

<body>
    <h1>The word-spacing Property</h1>

    <h2>word-spacing: length is -20px</h2>
    <p style="word-spacing: -20px;
              color: green; 
              font-weight: bold;
              font-size: 25px;">
        GeeksforGeeks - A Computer Science Portal For Geeks!
    </p>
</body>

</html>

Output:

Supported browsers: The browsers supported by word-spacing Property are listed below:

CSS word-spacing Property – FAQs

What is the purpose of the word-spacing property in CSS?

The word-spacing property controls the space between words in a text.

How do I increase the space between words in a paragraph?

Use word-spacing: 10px; to add 10 pixels of space between each word in a paragraph.

Can word-spacing accept negative values?

Yes, negative values like word-spacing: -2px; can reduce the space between words.

What is the default value of the word-spacing property?

The default value of the word-spacing property is normal, which sets the spacing to the browser’s default word space.

Does word-spacing affect inline elements?

Yes, word-spacing affects inline elements that contain text, such as <span> or <a>.


Next Article

Similar Reads

three90RightbarBannerImg