How to prevent long words from breaking a div with CSS?

Spread the love

Sometimes, we want to prevent long words from breaking a div with CSS.

In this article, we’ll look at how to prevent long words from breaking a div with CSS.

How to prevent long words from breaking a div with CSS?

To prevent long words from breaking a div with CSS, we set the white-space property.

For instance, we write

.word_wrap {
  white-space: pre-wrap;
}

to use white-space: pre-wrap; to break up long words so that they wrap to the next line.

Conclusion

To prevent long words from breaking a div with CSS, we set the white-space property.

Leave a Reply

Your email address will not be published. Required fields are marked *