Breaking Long URLs and Words
Sometimes in your content you end up with some really long words or URLs that just won't wrap and end up screwing up the width of your content (especially in IE 6), or just running off the edge of the page.
Some common solutions involve automatically shortening the word or URL to a character limit and putting three dots "..." after it. But what if you want the whole URL or word to be visible?
I think the perfect solution is to have the URL wrap like words in a sentence, but how do you tell the browser to split the URL up?
The answer is to use <wbr/>
, the Word Break tag. This gives the browser a spot where it can split the line up. For example:
http://www.thefutureoftheweb.com/<wbr/>blog/2007/1/<wbr/>breaking-long-urls
This example gives the browser two places where it can break the URL and wrap the parts onto different lines:
http://www.thefutureoftheweb.com/
blog/2007/1/
breaking-long-urls
Unfortunately, the <wbr/>
tag doesn't work in all browsers, only Firefox and Internet Explorer. Via QuirksMode, Gordon Mohr suggests another solution using CSS which makes <wbr/>
work in Opera:
wbr:after { content: "\00200B" }
This adds ​
after the <wbr/>
, an entity that achieves the same effect in Opera and Safari.
Unfortunately, neither <wbr/>
nor this CSS will work in Safari. You can try putting ​
directly into your HTML, but then you'll end up with weird squares in Internet Explorer 6. Don't you love browser compatibilities?
For more info, check out the QuirksMode page I mentioned above.