Note overflow-wrap: break-word only breaks long words that would overflow their container. word-break: break-all breaks between any characters, even mid-word. Use overflow-wrap for most cases and word-break: break-all only for data like hashes or URLs.
Note balance evenly distributes text across lines (best for headings). pretty avoids orphaned words on the last line (best for paragraphs). stable prevents text from reflowing while the user is editing. These require no JavaScript and are progressive enhancements.
Frequently asked questions
How does HTML & CSS handle wrap text?
HTML & CSS covers this with 3 copy-ready snippets on this page. The "<span> Inline Container" snippet in HTML & CSS uses `<span class="name">inline content</span>`.
Which code does the HTML & CSS example use?
The "<span> Inline Container" snippet uses `<span class="name">inline content</span>`, from the Text Elements section of the HTML & CSS cheat sheet.
What other HTML & CSS snippets are shown for "wrap text"?
Besides "<span> Inline Container", this page also shows "Word Break & Overflow Wrap", "Modern Text Wrapping".
Is there anything to watch out for?
Yes. For "<span> Inline Container": A span has no semantic meaning. Use it purely for styling a portion of text when no better semantic element exists.