CSS word-break Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
Typography

What You’ll Learn

The word-break property controls how words split at line edges — essential when long URLs, code, or unbroken strings would otherwise overflow.

01

Line breaks

Inside long words.

02

Syntax

Keyword values.

03

normal

Default value.

04

break-all

Any character.

05

keep-all

CJK text.

06

URLs

Prevent overflow.

Introduction

The word-break property in CSS is used to specify how words should break or split when reaching the end of a line. This property is particularly useful for controlling the behavior of text in situations where long words or URLs might disrupt the layout of your content.

By using the word-break property, you can ensure a more visually appealing and readable presentation of text on your website.

Definition and Usage

Apply word-break on containers with constrained width — cards, tables, chat bubbles, code blocks, and mobile layouts. It works alongside overflow-wrap and white-space to manage how text flows.

💡
Beginner Tip

For long URLs in narrow spaces, try word-break: break-all or overflow-wrap: anywhere. Use break-all carefully on regular paragraphs because it can split words mid-character and hurt readability.

📝 Syntax

The syntax for the word-break property is straightforward. It can be applied to any block or inline-level element.

syntax.css
element {
  word-break: normal | break-all | keep-all | break-word;
}

Basic Example

word-break.css
.url {
  word-break: break-all;
}

Syntax Rules

  • One keyword value at a time.
  • break-all is aggressive — best for URLs, hashes, and code tokens.
  • keep-all is mainly for CJK languages.
  • break-word is legacy; modern code often uses overflow-wrap: break-word instead.
  • The property is inherited.

Related Properties

  • overflow-wrap (& word-wrap) — allows breaking long unbroken strings
  • white-space — controls space collapsing and line wrapping
  • hyphens — adds hyphenation at break points when supported
  • text-overflow — ellipsis when text is clipped instead of wrapped

🎯 Default Value

The default value of the word-break property is normal, which uses the default line break rules for the content language.

⚡ Quick Reference

QuestionAnswer
Default valuenormal
Break long URLsword-break: break-all;
CJK no mid-word breaksword-break: keep-all;
Break only when neededword-break: break-word; or overflow-wrap: break-word;
Modern alternativeoverflow-wrap: anywhere;
InheritedYes

💎 Property Values

The word-break property accepts keyword values that control line breaking inside words.

ValueExampleDescription
normalword-break: normal;Uses the default line break rule (default).
break-allword-break: break-all;Breaks words at any character to prevent overflow.
keep-allword-break: keep-all;Prevents word breaks in CJK text. Non-CJK text behaves as normal.
break-wordword-break: break-word;Breaks words only when necessary to prevent overflow. Often replaced by overflow-wrap: break-word in modern CSS.
normal break-all keep-all break-word

When to Use word-break

word-break is helpful whenever unbroken strings meet narrow containers:

  • Long URLs in cards — Prevent horizontal scrolling on mobile.
  • Code snippets and tokens — Wrap JWT strings, hashes, and file paths.
  • Chat and comment UI — Handle user-pasted strings gracefully.
  • CJK typography — Use keep-all to respect word boundaries in Asian languages.
  • Data tables — Keep cells readable without breaking the table layout.

👀 Live Preview

Same long string with normal vs break-all in a narrow box:

Supercalifragilisticexpialidocious
normal
Supercalifragilisticexpialidocious
break-all

Examples Gallery

In this example, we’ll demonstrate the different values of the word-break property.

📜 Core Patterns

Compare how each word-break keyword handles long unbroken strings.

Example 1 — Compare all values

In this example, we’ll demonstrate the different values of the word-break property.

index.html
<style>
  .normal { word-break: normal; }
  .break-all { word-break: break-all; }
  .keep-all { word-break: keep-all; }
  .break-word { word-break: break-word; }
</style>

<div class="break-all">Longunbrokenstring</div>
Try It Yourself

How It Works

normal may overflow narrow boxes. break-all splits at any character to fit the container width.

Example 2 — Long URLs in a card

Prevent share links and documentation URLs from overflowing mobile layouts.

url.css
.url {
  word-break: break-all;
}
Try It Yourself

How It Works

URLs have no natural spaces, so break-all is a practical choice for narrow UI components.

📄 Language & Code

Handle CJK text and monospace tokens without layout breakage.

Example 3 — keep-all for CJK text

Prevent mid-word breaks in Chinese, Japanese, and Korean content.

keep-all.css
.cjk {
  word-break: keep-all;
}
Try It Yourself

How It Works

keep-all tells the browser not to break CJK words at arbitrary points, preserving natural reading flow.

Example 4 — Code and hash strings

Wrap long tokens in monospace blocks without horizontal overflow.

code.css
pre {
  word-break: break-all;
  font-family: monospace;
}
Try It Yourself

How It Works

Monospace code often contains unbreakable strings. break-all keeps the block within its container.

♿ Accessibility

  • Readability first — Avoid break-all on body paragraphs where mid-word splits confuse readers.
  • Zoom and mobile — Proper wrapping prevents horizontal scrolling, which helps users with low vision and motor difficulties.
  • Screen readers — Visual breaks do not change spoken text, but confusing layout can still hinder comprehension for some users.
  • Prefer overflow-wrap when possible — It breaks less aggressively than break-all for general content.

word-break + overflow-wrap

Modern layouts often combine both properties: overflow-wrap: break-word for soft wrapping, and word-break: break-all only where aggressive breaks are acceptable.

wrap-pair.css
.content {
  overflow-wrap: break-word;
  word-break: normal;
}

.url {
  word-break: break-all;
}

🧠 How word-break Works

1

Text reaches container edge

A long word or URL has no spaces to break on.

Input
2

word-break sets break rules

Keywords define whether breaks are allowed inside words.

Rules
3

Browser wraps or overflows

Text splits across lines or overflows if breaking is not allowed.

Layout
=

Contained readable text

Content fits the layout without breaking the page.

Browser Compatibility

The word-break property is supported in all modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. Test your layouts across browsers to ensure consistent wrapping behavior.

Modern browsers · Widely supported

Text wrapping control

All major browsers support normal, break-all, keep-all, and break-word.

99% Browser support
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions
Full support
Opera All versions
Full support

Testing tip

Test with real URLs, JWT tokens, and CJK sample text on narrow mobile widths.

word-break property 99% supported

Bottom line: word-break is safe to use for text wrapping control on the modern web.

Conclusion

The word-break property is an essential tool for web developers looking to control the behavior of text wrapping on their web pages.

By customizing how words break at the end of a line, you can enhance the readability and aesthetic appeal of your content. Experiment with different values of the word-break property to see how it can improve the layout and presentation of your text.

💡 Best Practices

✅ Do

  • Use break-all for URLs, hashes, and code tokens
  • Use keep-all for CJK body text when appropriate
  • Combine with overflow-wrap for flexible layouts
  • Test wrapping on mobile and with browser zoom
  • Set a max-width on text containers for readability

❌ Don’t

  • Apply break-all to entire article body text
  • Confuse word-break with white-space
  • Forget that break-word has modern alternatives
  • Ignore horizontal overflow on small screens

Key Takeaways

Knowledge Unlocked

Five things to remember about word-break

Use these points when handling long unbroken text.

5
Core concepts
🕐 02

normal

Default value.

Default
🔀 03

break-all

URLs & code.

Pattern
🔒 04

keep-all

CJK text.

i18n
🌐 05

overflow-wrap

Modern pair.

Companion

❓ Frequently Asked Questions

word-break controls how words and strings break when they reach the edge of a container, which helps prevent overflow from long URLs, code, or unbroken text.
The default value is normal, which uses standard line-breaking rules for the language.
break-all can break at any character to prevent overflow. break-word only breaks when necessary and prefers breaking at word boundaries when possible.
keep-all prevents word breaks in CJK (Chinese, Japanese, Korean) text. Non-CJK text behaves like normal.
Yes, word-break is inherited. Setting it on a parent affects child text unless overridden.

Practice in the Live Editor

Open the HTML editor and compare normal, break-all, and keep-all in narrow boxes.

HTML Editor →

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