CSS word-wrap Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The word-wrap property controls whether the browser may insert line breaks inside an otherwise unbreakable string — such as a long word or URL — so the text fits its line box instead of overflowing.

The initial value is normal. Unlike word-break, it breaks only when the whole word cannot fit on a line by itself. The standard name today is overflow-wrap; word-wrap is the same property under its older name.

Legacy alias.

Originally a non-standard Microsoft extension. It is now an official alias of overflow-wrap. Prefer overflow-wrap in new CSS; word-wrap still works widely for older code and tutorials.

CSS Syntax

syntax.css
word-wrap: normal | break-word | anywhere | initial | inherit;

Example: word-wrap: break-word;. Same keywords as overflow-wrap.

Property Values

ValueDescriptionTry it
normalDefault. Break only at normal points such as spacesTry it
break-wordMay break long strings to prevent overflow. Does not affect min-content sizingTry it
anywhereMay break long strings; soft wraps count for min-content sizeTry it
initialResets to the initial value, normalTry it
inheritTakes the value from the parent elementTry it

How to Use word-wrap

Constrain the text box, then choose whether long strings may break inside a word.

  1. Give the text a limited width (a card, sidebar, or max-width).
  2. Leave normal if words should only break at spaces.
  3. Set break-word for most UI text and long URLs in narrow boxes.
  4. In new projects, write overflow-wrap instead — same values, standard name.
PieceRequired?Role
Limited line widthYes (to see the effect)Without a narrow box, long words still fit on one line
KeywordYesnormal, break-word, or anywhere
overflow-wrapPreferred in new CSSStandard name; word-wrap is the alias
word-break / hyphensOptionalChange break style further when needed

Live Preview

A narrow box holds one long word. Change word-wrap and watch whether the word breaks or sticks out.

Box width stays fixed. Only the wrap keyword changes. Same behavior as overflow-wrap.

Box

word-wrap: break-word

CSS Examples

Each snippet focuses on word-wrap. The narrow width is only there so a long string can overflow. Use Try It Yourself for a live editor.

Example 1 — Default Normal

Long words stay intact and can stick out of a narrow box.

CSS
<style>
  p {
    width: 140px;
    word-wrap: normal;
    border: 1px solid #cbd5e1;
    padding: 8px;
  }
</style>

<p>Supercalifragilisticexpialidocious</p>
Try It Yourself

How It Works

  1. Limit the width. width: 140px makes a narrow line box.
  2. Keep normal. word-wrap: normal only allows breaks at spaces.
  3. One long word. There is no space inside the word, so it cannot wrap.
  4. Result: the word overflows past the border instead of breaking mid-word.

Example 2 — Break Word

Allow a mid-word break only when the whole word cannot fit.

CSS
<style>
  p {
    width: 140px;
    word-wrap: break-word;
    border: 1px solid #cbd5e1;
    padding: 8px;
  }
</style>

<p>https://example.com/very/long/path/name</p>
Try It Yourself

How It Works

  1. Same narrow box. The URL is longer than 140px.
  2. Set break-word. The browser may break inside the string to stop overflow.
  3. Only when needed. Short words that fit on a line still wrap normally at spaces.
  4. Common UI fix. Useful for cards, comments, and sidebars that show long links.

Example 3 — Anywhere

Break like break-word, and let those soft wraps affect min-content size.

CSS
<style>
  p {
    width: min-content;
    max-width: 140px;
    word-wrap: anywhere;
    border: 1px solid #cbd5e1;
    padding: 8px;
  }
</style>

<p>Supercalifragilisticexpialidocious</p>
Try It Yourself

How It Works

  1. Use min-content width. Intrinsic sizing asks how narrow the box can get.
  2. Set anywhere. Soft wrap opportunities inside the long word count toward that min size.
  3. Cap with max-width. max-width: 140px keeps the demo readable.
  4. Vs break-word. Visual wrapping looks similar here; the sizing difference shows up most in flex and grid min sizes.

Edge Cases & Pitfalls

If text still overflows or breaks too aggressively, check these first.

alias

Prefer overflow-wrap in new code

word-wrap still works as a legacy alias. Write overflow-wrap for clarity and standards alignment.

width

No narrow box, no visible wrap

If the container is wider than the long string, every keyword looks the same. Constrain width before comparing values.

word-break

Do not confuse with word-break

word-break: break-all can break even when a word would fit alone on the next line. word-wrap is the gentler, overflow-only option.

anywhere

anywhere changes min-content

In flex and grid, anywhere can let a box shrink smaller than break-word would. Prefer break-word unless you need that sizing behavior.

nowrap

white-space: nowrap blocks wrapping

If white-space prevents wrapping, word-wrap cannot create multi-line breaks. Fix white-space first.

Browser Support

word-wrap is a browser CSS property (legacy alias of overflow-wrap). Node.js, Deno, and Bun do not apply it.

✓ Baseline · Legacy alias

word-wrap

Widely supported as an alias of overflow-wrap. break-word works broadly, including older IE. anywhere needs modern browsers (same as overflow-wrap).

99% Alias support
Google Chrome Supported
Full support
Mozilla Firefox Supported
Full support
Apple Safari Supported
Full support
Microsoft Edge Supported
Full support
Opera Supported
Full support
Samsung Internet Supported
Full support
Internet Explorer 5.5+
break-word (no anywhere)
word-wrap Alias of overflow-wrap

Bottom line: Safe for legacy and modern browsers. Prefer overflow-wrap in new stylesheets. This is not a JavaScript runtime API.

Key Takeaways

  • Role: allow mid-word breaks only when a long string would overflow.
  • Alias: same as overflow-wrap. Prefer the standard name in new CSS.
  • Default: normal. Use break-word for most UI overflow fixes.
  • Gentler than word-break: only breaks when the whole word cannot fit alone on a line.

One line: word-wrap is the old name for overflow-wrap — learn it for legacy code, write overflow-wrap going forward.

Frequently Asked Questions

It controls whether the browser may break an otherwise unbreakable string, such as a long word or URL, so the text fits inside its line box instead of overflowing.
Yes. word-wrap began as a non-standard Microsoft name and is now a legacy alias of the standard overflow-wrap property. Prefer overflow-wrap in new CSS.
The initial value is normal. Lines break only at normal points such as spaces, so a very long word can stick out of a narrow box.
word-wrap (overflow-wrap) breaks a word only when that whole word cannot fit on a line by itself. word-break can force breaks more aggressively, depending on its value.
Use break-word for most UI text. Use anywhere when soft wrap opportunities should also affect min-content sizing in flex or grid layouts.
Yes. It applies to text and is inherited. It is a browser CSS property, not a Node.js feature.

Next: writing-mode

Learn how to set horizontal or vertical text flow.

writing-mode tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful