CSS Line Breaks & Wrapping — white-space, word-break, overflow-wrap, and line-break (CJK)

CSS wrapping after Markdown-to-HTML: when to use white-space, overflow-wrap, word-break, and line-break for CJK text. Patterns for code blocks, tables, and a checklist for print/PDF review.

What you’ll learn

Markdown is easy to author, but how lines break in the browser is a CSS concern. This page is a practical, document-focused primer.


Line breaks vs wrapping

For “overall polish,” see Better-Looking Markdown PDFs.


white-space — preserve spaces and newlines?

ValueTypical behavior
normalCollapse spaces, wrap when needed
nowrapNo wrapping; often overflows horizontally
prePreserve spaces and newlines; often paired with monospace fonts
pre-wrapLike pre, but can wrap at the line end
pre-linePreserve newlines; collapse spaces

Code blocks often use pre or pre-wrap. Plain pre can overflow on long lines unless overflow-x or wrapping is added.


overflow-wrap (word-wrap) — break inside long words?

Useful for long URLs or long tokens in paragraphs.


word-break — CJK and mixed-language breaks

ValueNotes
normalDefault behavior
break-allAny character can start a new line (can hurt readability in Japanese body text)
keep-allPrefer breaks between “words” in some scripts (behavior varies)

Avoid applying break-all to entire Japanese paragraphs. Scope it to problematic tokens.


line-break — stricter punctuation rules

Values like strict / loose influence line-breaking rules around punctuation. Browser support varies. Often you’ll use different rules for body text vs tables vs code.


hyphens — hyphenation for Latin text

hyphens: auto depends on language tags and font support. Don’t rely on it for Japanese-first documents.


Code blocks: common patterns

IssueApproach
Long horizontal linesoverflow-x: auto on pre, or white-space: pre-wrap
Readabilityfont-family with a monospace stack
Print/PDFSplit long lines in the source when needed

Fenced Markdown code usually becomes <pre><code>; your CSS determines the final look.


Tables and images

Tables often need combined width/table-layout/word-break tuning. Images usually need max-width: 100% to avoid overflow—more about layout than “line breaks” per se.


Checklist: Markdown → HTML → PDF

Open Markdown to PDF when you care about print layout.


FAQ

Should I word-break: break-all on everything?

Usually no for body text. Scope it to narrow columns or long tokens.

br vs CSS wrapping?

Use br for semantic line breaks. Responsive wrapping belongs to CSS.


Summary

Try the tools

ToolMarkdown to HTML (md to html)Preview .md in the browser, adjust layout, and download HTML.Open tool How-to & BlogBetter-Looking Markdown PDFs — Layout, Page Breaks, and a Practical Polish ChecklistImprove Markdown PDF visual quality: align screen vs print layout, fix margins, fonts, overflowing tables and code blocks, add cover pages and TOC. Includes a pre-delivery polish checklist.Read article How-to & BlogHow to Convert Markdown to HTML and PDF — Step-by-Step GuideFull guide to Markdown Document Converter: load files, switch view modes, tweak layout, download HTML, save PDF. Step-by-step with screenshots and FAQ for first-time users.Read article