CSS Reference Property

word-wrap 6hv6j

The word-wrap property is used to specify whether lines can break inside words that are so long that they would overflow their container and that are otherwise not breakable by default. 2o123h

How is it different from the word-break property breaks a line in between two characters of a word which comes at the end of this line, to make the whole line fit inside its container. But the word-wrap property, on the other hand, breaks a word when the word itself takes up an entire line and overflows that line; that is, when the word itself and on its own is too long that it would overflow its container, so we make it wrap just line a line would wrap to fit inside its container.

The word-wrap property only has an effect when white-space allows wrapping.

The word-wrap property is called overflow-wrap in the CSS Text Level 3 specification (which is still a Working Draft so things may change).

The two properties (word-break property breaks all words at the end of a line, even those that would normally wrap onto another line and wouldn’t overflow their container.

No hyphenation character is inserted at the break point of the word. Because of that, it would be wiser to use this property in conjunction with the hyphens property.

Official Syntax 4j1l4a

  • Syntax:

    word-wrap: normal | break-word
  • Initial: normal
  • Applies To: all elements
  • Animatable: no

Values 4w6m73

normal
lines may only break at normal word break points.
break-word
normally unbreakable words may be broken at arbitrary points if there are no otherwise acceptable break points in the line.

Examples 3y6d6i

The following line will break all words (inside paragraphs) that are too long and would normally overflow their container.

p {
    word-wrap: break-word;
}
                

Browser s162l

CSS3 Overflow-wrap 57l

Allows lines to be broken within words if an otherwise unbreakable string is too long to fit. Currently mostly ed using the `word-wrap` property.

W3C Working Draft

ed from the following versions:

Desktop 1i5h4c

  • 23
  • 49
  • 5.5
  • 12
  • 6.1

Mobile / Tablet 1u2r2g

  • 7.0
  • 4.4
  • all
  • 66
  • 60

* denotes prefix required.

  • ed:
  • Yes
  • No
  • Partially
  • Polyfill

Stats from caniuse.com

Further Reading g1037

Written by

Last updated June 11, 2020 at 10:55 pm by Mary Lou

Do you have a suggestion, question or want to contribute? Submit an issue.