Multilingual text can wrap differently even when the CSS appears correct. This guide explains how Unicode line breaking, browser text layout, and CSS properties work together, then provides a practical checklist for diagnosing clipped labels, unexpected breaks, CJK text wrapping, Thai line breaks, emoji behavior, and long unbroken strings.
Overview
Text wrapping is not based on spaces alone. A browser considers the characters in a string, their Unicode line-break properties, the surrounding characters, the available inline size, the selected font, and CSS rules such as white-space, overflow-wrap, and word-break. The result is a set of permissible line-break opportunities. The browser then chooses a suitable opportunity when the current line no longer fits.
Unicode Standard Annex #14, the Unicode Line Breaking Algorithm, provides a general model for these opportunities. Browsers can apply CSS and language-specific behavior on top of that model, so the same text may not wrap identically in every browser or writing system. Treat the Unicode algorithm as the foundation, not as a guarantee of pixel-identical output.
A compact reference to line-break classes
Unicode assigns line-break classes to characters and character sequences. The table below highlights classes that commonly matter during frontend debugging. It is a practical subset rather than a complete replacement for the Unicode data files or specification.
| Class | Typical meaning | Why it matters in a UI |
|---|---|---|
| AL | Alphabetic characters | Common letters in Latin and many other scripts; usually remain together according to normal word rules. |
| SP | Space | Creates a familiar break opportunity in many scripts. |
| BA / BB | Break-after / break-before | Used by punctuation or symbols that influence which side of a boundary may break. |
| HY | Hyphen | May permit a break after the hyphen, depending on surrounding rules and CSS. |
| OP / CL / CP | Opening, closing, and closing-parenthesis punctuation | Helps prevent lines from beginning or ending with unsuitable punctuation. |
| ID | Ideographic characters | Important for CJK text, where breaks can occur between many characters without spaces. |
| JL / JV / JT | Hangul leading, vowel, and trailing jamo | Prevents inappropriate breaks inside Korean syllable composition. |
| CM | Combining mark | Normally stays with its preceding base character; splitting it can damage visual meaning. |
| ZWJ | Zero width joiner | Helps connect emoji or script sequences and should not be treated as an ordinary visible break point. |
| RI | Regional indicator | Used in flag emoji sequences, where pairs should generally remain together. |
| WJ | Word joiner | Suppresses line breaks at its position. |
| GL | Glue | Discourages breaks between characters such as a non-breaking space and adjacent text. |
| BK / CR / LF / NL | Mandatory or paragraph-breaking controls | Represent explicit line or paragraph boundaries rather than optional wrapping. |
| XX | Unknown or unassigned behavior | Signals that the implementation should use its default handling or updated Unicode data. |
Line-break classes are properties of Unicode characters, not visual measurements. A class does not say how wide a glyph is, whether a font contains it, or whether a component has enough room. Those concerns belong to font selection, shaping, layout, and CSS.
Checklist by scenario
Latin labels that overflow their container
- Inspect the computed
white-space,overflow-wrap, andword-breakvalues. - Check whether the element has a constrained inline size and whether a flex or grid item has
min-width: autobehavior preventing it from shrinking. - Look for URLs, hashes, IDs, email addresses, or generated tokens with no ordinary break opportunity.
- Use
overflow-wrap: anywherefor emergency breaking inside arbitrary strings, especially in bounded cards or table cells. - Decide whether the visual design permits a break or whether truncation with an accessible full-text alternative is more appropriate.
CJK text that wraps unexpectedly
- Start with
word-break: normaland allow the browser's language-aware behavior to operate. - Set an appropriate
langattribute, such aslang="ja",lang="ko", orlang="zh-Hans", when the content language is known. - Check punctuation at line edges. Opening and closing punctuation may move or resist breaking according to line-breaking rules.
- Test narrow widths, not only desktop layouts. A break that looks acceptable in a wide panel may create an isolated punctuation mark on mobile.
- Use
word-break: keep-allonly when its effect is intentional; it can reduce useful break opportunities for some content.
Thai and other scripts without visible spaces
- Do not assume that the absence of spaces means the text cannot wrap. Browsers may use language-aware segmentation or dictionary-based behavior.
- Provide the correct
langvalue and test with the browser and operating systems your users actually use. - Compare
word-break: normalwith more aggressive settings only after verifying that the default behavior is the real problem. - Avoid inserting spaces merely to force layout. That changes the content and may affect copying, search, screen readers, and downstream processing.
Emoji, combining marks, and apparent character splits
- Test family emoji, skin-tone modifiers, flags, keycaps, and sequences joined with a zero width joiner.
- Remember that a user-perceived character can contain multiple code points. Unicode line breaking and grapheme-cluster boundaries are related but not identical concepts.
- Avoid manually slicing strings by JavaScript code-unit index when creating labels or truncation logic. A split can separate a surrogate pair, combining mark, or emoji sequence.
- If the issue involves presentation rather than wrapping, review variation selectors and rendering behavior in addition to CSS.
URLs, hashes, and generated identifiers
- Choose a deliberate policy: wrap, scroll, clip, or truncate.
- For a wrap policy, test
overflow-wrap: anywhereand confirm that the result remains readable. - For code or data, consider
white-space: pre-wrapso existing whitespace is retained while long lines can still wrap. - Do not use
word-break: break-allas a universal fix. It can break ordinary words at arbitrary points and harm readability.
What to double-check
When debugging internationalized text wrapping, change one variable at a time. Begin with the actual string and its language metadata, then inspect computed styles and the element's layout constraints.
white-space:normalpermits ordinary wrapping;nowrapsuppresses it;prepreserves whitespace and generally prevents automatic wrapping;pre-wrappreserves whitespace while allowing wrapping.overflow-wrap:break-wordor, where supported and appropriate,anywherehelps contain unusually long strings.anywherecan affect intrinsic size calculations, so verify flex and grid behavior.word-break:normalis a sensible baseline.break-allis especially disruptive for Latin words.keep-allchanges behavior for scripts where breaks between characters may otherwise be available.hyphens: automatic hyphenation depends on language, browser, platform, and available hyphenation resources. Treat it as an enhancement, not the only overflow defense.- Language metadata:
langcan influence hyphenation, pronunciation, segmentation, and other language-sensitive behavior. Apply it to the smallest accurate region when a page contains multiple languages. - Layout context: inspect flex items, grid tracks, tables, replaced elements, and nested containers. A text rule cannot fix a parent that refuses to shrink.
- Fonts and fallback: missing glyphs, fallback fonts, and different font metrics can change line width and therefore the point at which a break occurs.
For Unicode-specific investigation, compare code points and encoding only after confirming that layout is the issue. The references on code points, UTF-8, and UTF-16 and grapheme clusters and emoji-aware string length are useful when a string appears to contain invisible or unexpected characters.
Common mistakes
- Using
word-break: break-alleverywhere: This may eliminate overflow but makes normal prose harder to read and can produce unnatural breaks. - Assuming spaces define all break opportunities: CJK, Thai, emoji sequences, punctuation, and combining marks follow different constraints.
- Fixing content with inserted spaces or hyphens: Artificial characters can change meaning, search behavior, copy-and-paste results, and accessibility output.
- Testing only one translation: Short source text can expand substantially in another language, while scripts without spaces can expose different layout assumptions.
- Confusing code points with visible characters: A displayed symbol may contain several code points, and a single code point may render differently by font or context.
- Ignoring explicit line breaks: Newline characters, HTML elements, and generated content can create breaks that are unrelated to automatic wrapping.
- Truncating with JavaScript string slicing: Index-based truncation can split surrogate pairs or grapheme clusters. Prefer CSS where possible, or use a Unicode-aware segmentation approach.
- Assuming browser behavior is identical: Language segmentation, fonts, hyphenation, and newer CSS behavior may vary. Test representative browsers rather than relying on one screenshot.
When to revisit
Revisit this checklist before a major responsive redesign, a localization release, or any change to typography, component libraries, or browser support. It is also worth repeating before seasonal planning cycles when marketing labels, navigation, and promotional content change rapidly.
Update your test set when you add a language or writing system. Include short labels, long headings, paragraphs, names, dates, currency, URLs, user-generated text, emoji, and strings containing combining marks. Test at narrow and wide widths, with zoom or larger text enabled where relevant, and in the browsers supported by your product.
Keep a small regression page in your project with representative samples for Latin, CJK, Thai, mixed-script text, punctuation-heavy content, emoji sequences, and long unbroken strings. Record the intended outcome for each sample: ordinary wrapping, preserved whitespace, safe emergency breaking, scrolling, or truncation. When a browser, framework, font, or Unicode data update changes the result, compare it against that documented intent rather than treating every visual difference as a defect.
As a final action, inspect the component in developer tools, confirm its computed CSS and lang value, then test the real translated strings at the smallest supported width. This simple sequence usually distinguishes a Unicode line-breaking issue from a container, font, or content problem—and gives the next developer a reproducible fix.