Web Development Blog

by Ei Sabai Nyo

25 Feb, 2009

Wrapping a long url with CSS    

a {
word-wrap: break-word;
}

Works for a long text too:

p {
word-wrap: break-word;
}

Tested in IE6, IE7, Firefox, Safari, Chrome

Love what you've just read? Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
Your name:   Your email:  

3 Responses to “Wrapping a long url with CSS”

  1. max says:

    Mmmm… This solution not validate and doesn’t work w many browsers!
    did you try:

    white-space: pre-wrap; /* css-3 */
    white-space: -moz-pre-wrap !important; /* Mozilla */
    white-space: -pre-wrap; /* Opera 4-6 */
    white-space: -o-pre-wrap; /* Opera 7 */
    word-wrap: break-word; /* IE 5.5+ */

    It’s still not css validate but works w many browsers

  2. alinur says:

    CSS means Cascading style Sheet. This the language of web page design.

  3. Jürgen Jeka says:

    Max,

    word-wrap: break-word;
    works in Gecko 1.9.1/ Firefox 3.5. See
    https://developer.mozilla.org/en/CSS/word-wrap

    BTW, white-space: pre-wrap;
    works since Gecko 1.9/ Firefox 3.0, -moz-pre-wrap is dropped. See
    https://developer.mozilla.org/en/CSS/white-space

    j.j.

Profile PicHello! Welcome to Web development blog! My name is Ei Sabai and on this blog, I write about web development, mobile app development, latest web technologies and the likes. Read more about me or have a look at some of the tips & resources I've written.
Subscribe to our newsletter to receive tips, resources and special offers related to web development & design.
We do NOT spam.
Your name:  
Your email:  

Tips & Resources

Tips & Resources
WordPress Web Hosting
Recommended web hosting providers for WordPress 3.0
iPhone Native App Development
Important steps into iPhone app development for beginners
iPhone Web App Development
Tips for iPhone web app development
Coupons for Web Developers
Get discounts on web hosting, domain names, templates, etc
10 Useful jQuery Snippets
Easy-to-use jQuery snippets for any website
HTML Email Newsletter
Step-by-step tutorial on how to code an HTML email newsletter
  • bluehost Hosting $6.95/month
  • Joomla Templates

Recommended Book

Categories