W3docs

CSS word-wrap Property

Use the word-spacing CSS property to break even unbreakable word to fit the container. Read about property values and try examples.

The word-wrap property breaks long words so they fit within their container. This property allows breaking words that would otherwise overflow.

The property controls how long words are handled when they exceed the container's width. It does not accept positive or negative values; those belong to the word-spacing property. When set to normal, words break only at allowed break points.

The word-wrap property is one of the CSS3 properties.

It only has an effect when the white-space property allows wrapping.

Info

In modern CSS, word-wrap is an alias for the overflow-wrap property.

Initial Valuenormal
Applies toAll elements.
InheritedYes.
AnimatableNo.
VersionCSS3
DOM Syntaxobject.style.wordWrap = "break-word";

Syntax

CSS word-wrap values

word-wrap: normal | break-word | initial | inherit;

Example of the word-wrap property with the "normal" value:

CSS word-wrap code example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        width: 120px;
        border: 1px solid #666;
        word-wrap: normal;
      }
    </style>
  </head>
  <body>
    <h2>Word-wrap property example</h2>
    <div>
      Lorem Ipsum is
      <strong>simplysimplysimplysimplysimplysimply</strong> 
       dummy text of the printing and typesetting
      <strong>industryindustryindustryindustryindustry</strong>.
    </div>
  </body>
</html>

Result

CSS word-wrap property

Example of the word-wrap property with the "break-word" value:

CSS word-wrap break-word example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      div {
        width: 120px;
        border: 1px solid #666;
        word-wrap: break-word;
      }
    </style>
  </head>
  <body>
    <h2>Word-wrap property example</h2>
    <div>
      Lorem Ipsum is
      <strong>simplysimplysimplysimplysimplysimply</strong> 
      dummy text of the printing and typesetting
      <strong>industryindustryindustryindustryindustry</strong>.
    </div>
  </body>
</html>

Values

ValueDescription
normalBreaks words only at allowed break points. This is the default value.
break-wordAllows breaking unbreakable words if they exceed the container width.
initialSets the property to its default value.
inheritInherits the property from its parent element.

Practice

Practice

Which statement is correct about CSS word-wrap property?