CSS word-break

The word-break property in CSS is used to specify how words should be broken and wrapped when they are too long to fit within their container.

There are several possible values for the word-break property:

Let's see some examples to better understand how the word-break property works:

Result:

This is a verylongwordthatwillbreaknormally

This is a verylongwordthatwillbreakall

This is a verylongwordthatwillkeepall

In the example above, we have a container with a fixed width that contains text that is too long to fit within the container. The word-break property is applied to each paragraph to demonstrate the different behaviors.

The first paragraph has word-break: normal;, so the word breaks only at allowed break points. The second paragraph has word-break: break-all;, so the word breaks at any character. The third paragraph has word-break: keep-all;, so the word breaks only at allowed break points except for certain languages.

Experiment with different values of the word-break property to see how it affects the text wrapping in your own projects!