CSS Text Wrap Generator
Generate CSS for text wrapping and overflow: white-space, word-break, overflow-wrap, hyphens and text-wrap, plus single-line ellipsis or multi-line clamp. Test long words and URLs in a resizable live preview, read a plain-English explanation and copy the CSS.
Input
Only used for the preview and HTML snippet. Add long words, URLs, extra spaces or line breaks to test.
How spaces and line breaks are handled, and whether lines wrap.
The usual fix for long URLs. Also known by its legacy name, word-wrap.
auto needs a lang attribute on the element; the HTML snippet sets lang="en".
balance evens out heading lines; pretty avoids a lone last word in paragraphs.
Narrow the box to see where lines break.
Output
Your wrapped text will appear here.
More ways to use this tool
REST API
curl -X POST https://api.iotools.cloud/v1/tool/css-text-wrap-generator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "Long words like Pneumonoultramicroscopicsilicovo…",
"whiteSpace": "normal",
"wordBreak": "normal",
"overflowWrap": "anywhere",
"hyphens": "manual",
"textWrap": "wrap",
"overflow": "visible",
"lineClamp": "2",
"boxWidth": "240",
"fontSize": "18",
"textColor": "#1f2937",
"bgColor": "#f8fafc"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `css-text-wrap-generator` tool (CSS Text Wrap Generator) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.
Embed widget
<iframe
src="https://iotools.cloud/embed/css-text-wrap-generator/"
width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
title="CSS Text Wrap Generator — iotools.cloud"
sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
allow="clipboard-write"
style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>Drop this into your own page — free, no key required, just a link back.
| Cost per API/MCP call | From 5 credits |
|---|---|
| Need more credits? | View pricing |
Also available with
Guides
Long URLs that push past the edge of a card, file names that need an ellipsis, headings that end with one word alone on the last line: these are all text-wrapping problems. CSS splits the fix across several properties: white-space, word-break, overflow-wrap, hyphens, text-wrap and the overflow rules. This generator puts them in one place. You can try them on your own text in a box you can narrow, and it explains in plain English what each setting does.
How to use it
- Paste sample text. Include the awkward parts, like a long URL, a hash, extra spaces or line breaks.
- Choose
white-space. This controls whether spaces and line breaks are kept and whether lines wrap at all. - Set
word-breakandoverflow-wrap. These decide whether, and how, a word that is too long gets split. - Optionally turn on
hyphens: autoor a moderntext-wrapmode (balanceorpretty). - Pick an overflow mode. Choose visible, hidden, scrolling, a single-line ellipsis or a multi-line clamp.
- Change the box width to see exactly where lines break, then copy the CSS.
Common recipes
- Stop long URLs breaking the layout:
overflow-wrap: anywhere;. It breaks only the word that doesn't fit. Useanywhererather thanbreak-wordinside flex items, grid cells and tables, because onlyanywherelets the container shrink. - Truncate to one line with "…":
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;. The element also needs a width, or amin-width: 0flex parent. In ellipsis mode the generator forcesnowrapfor you. - Show only the first N lines:
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden;. Every current browser supports the prefixed form, so the generator emits it alongside the standardline-clamp. - Keep code-style spacing: use
white-space: pre(never wraps) orpre-wrap(keeps spacing but still wraps). - Tidier headings:
text-wrap: balanceevens out the line lengths, andtext-wrap: prettykeeps a lone word off the last line of a paragraph.
word-break vs overflow-wrap
word-break: break-all splits every word wherever the line ends, short ones included. overflow-wrap only steps in for a word that can't fit on a line of its own. For ordinary text with the occasional long URL, overflow-wrap is almost always the right choice. The old name word-wrap is an alias for overflow-wrap. word-break: break-word is deprecated, which is why it isn't offered.
For spacing between letters, words and lines, use the CSS Text Spacing Generator. For underlines and strikethroughs, see the CSS Text Decoration Generator.
Privacy
Everything runs in your browser. Your text and settings are never uploaded.