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

Front, Programming

Make a Unique Folded Corner Effect – Step By Step Guide

Front, Programming

Keyframes in CSS Explained – Make Your Animations Stand Out

Back, Programming

How To Use Absolute Paths In A Node Project (2024)

Programming

Javascript Array Methods – Easy Examples That Make Learning A Blast

Front, Programming

How To Make CSS Reflection – The Easy Way

Front, Programming

The Unique CSS Opacity – Check Out This Amazing Property

Front, Programming

Contrast And Brightness: Empower CSS Filter For Powerful Images

Front, Programming

Opacity And Saturate: Empower CSS Filter For Unique Images

Front, Programming

CSS Last Child Selector – The Most Valuable Selector

Front, Programming

What Does span Do in HTML? Unlocking Its Full Potential

Front, Programming

Most Useful HTML Elements for Maximizing Better Results

Front, Programming

HTML Formatting Elements Made Simple: With Easy And Practical Examples

Subscribe to our newsletter

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

Intuit Mailchimp