Text processing and international layout
Definition and purpose
CSS text processing governs how source whitespace becomes displayed space, where lines can wrap, and whether language-dependent hyphenation or emphasis marks are used. HTML lang and dir provide language and direction information; CSS does not replace these semantics.
Preserve source line breaks
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { white-space-collapse: preserve; text-wrap-mode: wrap; margin: 0; line-height: 20px; } </style> </head> <body> <p id="a" lang="en">One two three</p> <p id="b" lang="ja">日本語</p> </body></html>The explicit newline creates a second 20px line.
Syntax and mental model
white-space-collapse: preserve keeps sequences of spaces and segment breaks; text-wrap-mode: wrap permits soft wrapping. hyphens: auto can use a language dictionary when available. Soft hyphens can mark discretionary positions, but line breaking varies with language, font and engine. text-emphasis can add marks to text, commonly useful in East Asian typography. Use actual text content or semantic emphasis for meaning rather than decorative marks alone.
Language-specific requests
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #a { hyphens: auto; } #b { text-emphasis-style: filled dot; } </style> </head> <body> <p id="a" lang="en">One two three</p> <p id="b" lang="ja">日本語</p> </body></html>The properties request hyphenation and dots; dictionary and glyph rendering are not guaranteed by computed values.
Common mistakes
Do not force arbitrary breaks in Persian identifiers or use white-space: nowrap on all text. Test language-specific typography with real content and use overflow-wrap when needed for long unbreakable strings.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Font palettes and feature values. Next lesson: Font metrics and layout stability.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Text processing and international layout — knowledge check
Five questions on text processing and international layout.
Which attribute identifies content language?
What does preserve retain?
What does text-wrap-mode: wrap permit?
What can affect hyphens: auto?
Why not rely on emphasis dots for essential meaning?