How to Stop Long Words and URLs Breaking Your Blog Layout (2026)
Are long words breaking your blog layout? Maybe your sidebar suddenly dropped below the content, a comment stretched off the edge of the screen, or your mobile page started scrolling sideways, all without you changing the theme. The cause is often a single unbreakable string of text. Here is why it happens and the simple CSS fix that prevents it for good.

Quick answer: Browsers won’t wrap a word or URL that has no spaces, so a long string can push past its container and break your layout. Add overflow-wrap: anywhere; (or overflow-wrap: break-word;) to your content, sidebar and comment areas, give flex and grid children min-width: 0, and keep tables and code blocks in containers with overflow-x: auto. Then test on a phone-sized screen.
Table of Contents
Why long words and URLs break your blog layout
Browsers normally wrap text only at spaces and hyphens. A string with no break points, such as a very long word, a URL, or words joined with slashes like word1/word2/word3/word4, is treated as one unbreakable unit. If it is wider than its box, it either overflows the box or forces the box to grow, pushing neighbors out of place.
A real example from 2006
In the days of fixed-width, two-column 750px blog templates, our right sidebar suddenly slipped below the main content, even though the layout hadn’t been touched for a week. It looked fine in Firefox, but Internet Explorer was far less forgiving and broke the template completely. Reducing the sidebar width didn’t help.
After many CSS tweaks, the culprit turned out to be a post title: Hexakosioihexekontahexaphobia (the fear of the number 666), written for 6/6/06. The sidebar’s recent posts list tried to fit that one enormous word into a narrow column, and the whole template broke. Changing the post’s timestamp to move it out of the recent posts list restored the layout instantly. Internet Explorer has since been retired, but the underlying problem is the same in every modern browser.
Where long strings sneak in
- Recent posts and popular posts widgets showing long titles.
- Comments where visitors paste long URLs or type unbroken strings.
- Embedded feeds and link lists from other sites.
- Code snippets, file paths and email addresses in posts.
- Wide tables and images that don’t scale down on mobile.
On today’s responsive themes, the symptom is usually not a dropped sidebar but a page that scrolls sideways on phones, which looks broken and hurts the reading experience.
How to fix long words breaking your blog layout with CSS
1. Let long words wrap
Add this to your theme’s custom CSS (in WordPress: Appearance > Customize > Additional CSS, or your block theme’s styles):
.entry-content, .widget, .comment-content {
overflow-wrap: anywhere;
}According to MDN’s overflow-wrap reference (external site, opens in new tab), anywhere lets an otherwise unbreakable string break at any point if there is no other break opportunity, and no hyphen is inserted. The older value break-word works similarly but doesn’t affect how wide the box tries to be. The legacy name word-wrap is still supported as an alias.
2. Fix flex and grid layouts
Modern themes use flexbox or CSS grid for columns. Flex and grid items can refuse to shrink below their content width, so one long word can still widen a column. Add:
.site-main, .sidebar {
min-width: 0;
}3. Contain tables and code blocks
Some content shouldn’t wrap. Let it scroll inside its own box instead of stretching the page:
pre, .wp-block-table {
overflow-x: auto;
}4. Add hyphenation for long words (optional)
hyphens: auto; lets the browser hyphenate words at line breaks. Per MDN’s hyphens reference (external site, opens in new tab), it only works when the page or element has a correct lang attribute and the browser has a dictionary for that language.
5. Shorten what you control
- Use descriptive link text instead of pasting raw URLs.
- Add spaces around slashes in titles (“word1 / word2”).
- Insert a soft hyphen (
­) inside genuinely long words in titles.
Test before you trust
Always check your blog at phone width after changing the layout. Use your browser’s developer tools (responsive mode) and try a test comment with a long URL. Google’s mobile-first indexing means the phone version is the one that counts.
For more layout help, read how to make your site mobile-friendly for free, see how many WordPress theme columns you need, and check the essential web design elements your site needs.
FAQ
What is the difference between overflow-wrap and word-break?
overflow-wrap only breaks a word when it can’t fit on its own line, so normal text is unaffected. word-break: break-all breaks words more aggressively, even when not needed, which can look odd for regular text.
Why does my mobile site scroll sideways?
Usually something is wider than the screen: a long URL or word, a wide table, a fixed-width image or embed. Find it with your browser’s developer tools and apply the fixes above.
Will these CSS fixes affect normal text?
No. overflow-wrap only kicks in for strings too long to fit, so ordinary paragraphs wrap exactly as before.
Can long URLs in comments break my theme?
Yes, especially in narrow comment areas. Apply overflow-wrap: anywhere to the comment content class to keep them inside the box.

Subscribe to our weekly tech newsletter
Free: 100 Tech Terms ebook (worth $2.99)
Unsubscribe anytime. Privacy








very true..
even when you post paths like start>programfiles>software_name>subname>subname…
than too this kind of problem arises so I always use space between the terms like start > programfiles etc..