word-spacing

Word-Spacing is a CSS property used to adjust the horizontal space between words within a block of text.

Values

  • normal: Default value, sets spacing according to the font’s metrics.
  • length: Specifies a fixed amount of space (e.g., 10px, 1em).
  • percentage: Sets spacing relative to the font size (e.g., 50%).
  • inherit: Inherits the value from the parent element.

Syntax

word-spacing: value;

Examples

Set a fixed space of 10 pixels between words

p {
    word-spacing: 10px;
}

Set a space of 50% of the font size between words

h1 {
    word-spacing: 50%;
}

Inherit word-spacing from the parent element

.child-element {
    word-spacing: inherit;
}

Tips

  • Experiment with different values to achieve the desired spacing effect.
  • Consider the font family and size when setting word-spacing, as they can influence the overall appearance.
  • Use a combination of letter-spacing and word-spacing for more precise control over text spacing.
  • Be mindful of readability when adjusting word-spacing. Excessive spacing can make text difficult to read.

Additional Notes

  • Browser Compatibility: word-spacing is widely supported across modern browsers.
  • Accessibility: While word-spacing can improve readability for some users, it’s essential to consider the potential impact on users with visual impairments.