word-wrap

Term side of the Card.
Topic: Text Handling
Unit title: word-wrap
Categories: Property
Explanation side of the Card

Explanation: The legacy name of `overflow-wrap`, kept by browsers for compatibility. With 'break-word' it lets long words or URLs break to avoid overflow. New code should use `overflow-wrap` instead.

Browser compatibility:
  • The chrome browser supports this feature starting from version 80.
  • The edge browser supports this feature starting from version 80.
  • The firefox browser supports this feature starting from version 72.
  • The safari browser supports this feature starting from version 13.1.
Availability: 

Example

Wrongcss
.comment {
  word-wrap: break-word;
}
Rightcss
.comment {
  overflow-wrap: break-word;
}

word-wrap is a legacy alias; overflow-wrap is the standard name with the same 'break-word' behavior.

Common mistakes

  • Copying word-wrap: break-word from old snippets instead of the standard name.

Key points

  • New code uses overflow-wrap, with word-wrap only as an extra legacy line if at all.
  • Long words are broken with 'break-word' or 'anywhere', not with word-break: break-all.

Interview questions

Does word-wrap still work?

Yes. Browsers keep word-wrap as an alias of overflow-wrap for compatibility, but it is not the standard name.

Does word-wrap support the anywhere value?

As an alias it accepts the same values as overflow-wrap, but use overflow-wrap: anywhere to be clear.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy