Search code examples
cssword-break

What is an alternative to word-break : break-word; in CSS since it's deprecated and invalid by W3C standards?


I don't want the words to be break, but if the word is too long and the word could be breaked.¨

I used word-break: break-word;

But when validating the CSS in this it gives error: The value break-word is deprecated

I used alternatives offered in StackOverflow:

word-break: break-all;  it breaks all words even if the word is not that long-
word-break: normal;
word-break: initial;

word-wrap: break-word;
word-wrap: break-spaces;

overflow-wrap: normal;
overflow-wrap: break-word;

line-break: normal;
line-break: strict;
line-break: anywhere;

But none of them works. Either they break all the words - even short ones - or they don't break long words when the word is extending the div-space.

The only code that works is word-break: break-word; but that is deprecated.

What is an alternative to word-break: break-word; ??


Solution

  • I had the same problem and found that overflow-wrap: anywhere worked for my case. Credit: https://github.com/w3c/csswg-drafts/issues/2682#issuecomment-438693305