CSS Word Spacing – How to Do It Right

Photo of author

Marilena

Bookmark this post

Hey everyone! 😃 In this post, we’ll take a look at the CSS property called word spacing. It controls the horizontal distance between words in a text. By default, the CSS word spacing is set to 0px, which is known as normal (word-spacing: normal). If you increase the spacing value, the distance between words will get bigger, while decreasing it will make the spacing smaller.

Let’s take a closer look at this simple yet useful CSS property to understand it better.

HTML structure for CSS word spacing

Let’s begin by creating an HTML document. In it, we include three headings <h1> that display the text “Hello World”. The first heading has the class .spacing-normal, the second heading has the class .spacing-big, and the third heading has the class .spacing-small. All headings contain the same text, as it allows an easy comparison. 👌

<h1 class="spacing-normal">Hello World</h1>
<h1 class="spacing-big">Hello World</h1>
<h1 class="spacing-small">Hello World</h1>
HTML

CSS structure for CSS word spacing

For our CSS structure, we set the word-spacing property for all three classes and differentiate them by assigning different values.

.spacing-normal {
  word-spacing: normal;
}

.spacing-big {
  word-spacing: 100px;
}

.spacing-small {
  word-spacing: -50px;
}
CSS

The image below shows the impact of different word spacing values used for each of our headings. The first heading has normal word spacing, while the second has a larger distance between words due to the increased word spacing value. Similarly, the third heading has a narrower spacing resulting from the decreased value.

🔖 It is important to avoid using word spacing values that are either too large or too small.

In summary, this image demonstrates how adjusting the spacing between words can impact text appearance. It’s amazing how even small changes can have a significant impact. Isn’t it? 😎

🌼 Hope you found my post interesting and helpful. Thanks for being here! 🌼

DigitalOcean Referral Badge
guest
0 Comments
Inline Feedbacks
View all comments

Continue reading

Back, Programming

What Is A Cron Job? Everything You Need To Know About The Ultimate Task Manager

Front, Programming

The Unique CSS Opacity – Check Out This Amazing Property

Front, Programming

Most Useful HTML Elements for Maximizing Better Results

Front, Programming

Learn How to Select Only the CSS First Child

Front, Programming

The CSS nth-of-type Selector – How To Target Elements By Type

Front, Programming

What You Need to Know About CSS nth child Selector – A Practical Guide

Front, Programming

CSS Selectors nth-child VS nth-of-type And How To Use Them Correctly

Front, Programming

Coding Made Easy With CSS Selectors: An Ultimate Guide

Front, Programming

How to Center in CSS Using Different Ways

Front, Programming

What You Need to Know About CSS Color Methods

Programming

Most Common Typescript Errors and How to Solve Them

Front, Programming

Make Your Work Easier by Using Variables in CSS

Subscribe to our newsletter

Dive into the Fun Side of Tech! Posts, News, and More Delivered to Your Inbox!

Intuit Mailchimp