CSS Word Spacing
What Word Spacing in CSS?
One of the job of word-spacing property is to regulate space between every word that makes up a block of text.
Default Word Spacing:
Uses the default word spacing.
p {
word-spacing: normal;
}
Space is occasionally the norm and doesn't use any special line space.
Increased Word Spacing:
Adds extra space between words.
h1 {
word-spacing: 5px;
}
This example increases the space between words by 5 pixels.
Decreased Word Spacing:
Reduces the space between words.
article {
word-spacing: -2px;
}
This example decreases the space between words by 2 pixels.
Em Unit for Word Spacing:
Uses the em unit to set word spacing relative to the font size.
p {
word-spacing: 0.5em;
}
This example sets the word spacing to half of the font size.
Percentage Word Spacing:
Sets word spacing as a percentage of the normal word spacing.
p {
word-spacing: 150%;
}
This example increases word spacing to 150% of the default spacing.
Responsive Word Spacing:
Uses media queries to adjust word spacing based on the screen width.
p {
word-spacing: 10px;
}
@media screen and (max-width: 600px) {
p {
word-spacing: 5px;
}
}
Here includes different interline distances for miniaturized screens.