How to word-wrap long text in HTML?

In HTML a very long text is not automatically wrapped. Especially if there are no spaces in your string your browser doesn’t necessarily know where it should break the line.

no-wrap

In most cases you don’t want the people use the horizontal scrollbar to read the entire text but CSS allows you to force the browser to show all the text in multiple lines. CSS offers the properties white-space and word-wrap for this purpose.

div {
    white-space: pre-wrap;      /* CSS3 */
    white-space: -moz-pre-wrap; /* Firefox */
    white-space: -pre-wrap;     /* Opera <7 */
    white-space: -o-pre-wrap;   /* Opera 7 */
    word-wrap: break-word;
}

After applying the above rules on your text containers the result looks as follows.

wrap

Different browsers don't handle long text the same way. In firefox the long text got already wrapped without the CSS rules applied. It was able to detect special characters that were url-encoded and broke the lines on these positions.

firefox-wrap

Nonetheless you should never rely on this automatic detection but teach every browser that you really want to wrap so that you get the same result everywhere.

199 Comments

  1. Heiser a typically chosen body for school buses showing Kenworth chassis,
    could later be purchased Foundry Company and by Pacific Auto in 1937.

  2. Ett lån utan UC kommer icke handla dig någon service
    villig innerlig reslig sikt. Det befinner si synnerligen federala lån såsom inte ber dig att
    innehav någon viss krita rekord. Dessa lån kan fås a någo
    kredit evaluering unionen alternativ kanhända någo avlöna dagen lån affärsverksamhet.
    Federal studerande lån ej behöver n en kredit-värdering-kontrollera-eller co-signer.

    Få en lån utan UC kolla hela tiden en ofta eggande lott,
    ity det är någon utprovnin från krita skattning värdighet
    itu en annan eller någo anstalt. Studenter såsom inte
    äge fallerat gällande eventuella förra lån samt inneha ett arrogant
    krit skattning skulle vet klara a e lån utan UC.

    Dessa kan aldrig bearbeta sannolikheten stä godkännande förut denna ungefär från lån utan UC.
    Det finns otaliga lån som icke kräver en krit skattning övervaka.

    Lån Utan UC inspektion åt nödsituationer befinner sig absolu någo ännu flera sort
    av belägenhet såso kommer att göra anspråk på att ni tycker att ordna finansiering.
    Ingen kredit skattnin kontroll lån befinner si stä do såsom inneha ett
    faslig kredit. Den främsta anledningen åt att lån utan UC kol befinner
    si faktiskt odla populära befinner sig de långivare
    ej kontrollerar din egen lån värdering före ni erbjuder de slantar.

    Minsann, det finns sättför att erhåll studielån utan kreditupplysning villig det minsta.

  3. I read this piece of writing fully regarding
    the difference of most up-to-date and previous technologies,
    it’s awesome article.

  4. I’d like to thank you for the efforts you’ve put in penning this blog.

    I’m hoping to check out the same high-grade blog posts from you in the future
    as well. In fact, your creative writing abilities has inspired me to
    get my own, personal website now ;)

  5. left so quickly, I said how it happened, and teh girl in to the phone said thats just Carolyn. Think itrrrs great was justification! No longer!!!

  6. Thanks for finally writing about > How to word-wrap long text in HTML?
    | Slopjong < Liked it!

  7. It’s not my first time to pay a visit this website,
    i am visiting this web site dailly and obtain pleasant
    information from here everyday.

  8. Wow, that’s what I was exploring for, what a stuff! present here at this
    weblog, thanks admin of this web site.

  9. Herpes results in no symptoms or break outs in some people, though it continues to be
    contagious in all contaminated.

  10. CDPoker, LuckyAcePoker, Titan Poker et Bodog Poker sont les partenaires
    actuels.

  11. The corporate’s working profit went up by 598% from SEK51.2 million in the corresponding interval final yr to SEK81.eight million this 12 months.

    Also, the organization’s working margin augmented from 27.2% to 31.7%.

  12. Thanks for another informative blog. Where else could I get
    that type of info written in such a perfect approach? I have a venture that I am just now operating on, and I’ve been at the glance
    out for such information.

  13. Sure it has kettlebells and barbells, and all the usual things and exercises you see in most gyms.
    Also, distorted views of what ‘getting too big’ is exactly,
    are a worry. Do the study, learn the procedures and then let
    go a little, after all you are there because you want to do a skydive.

  14. The opportunity of Pennsylvania on-line gambling regulation is working its means into the ongoing price range deadlock within the state,
    protecting hopes for 2015 alive.

  15. J’ai donc décidé de partir vivre à Malte en Mars 2012.

  16. Il n’y a aucun coût et aucune limite au plaisir que vous pourriez avoir sur Rejoignez des hundreds of thousands d’utilisateurs PokerStars du monde entier et montrez-leur
    ce dont vous êtes capable.

  17. Why users still use to read news papers when in this technological world everything is accessible on net?

  18. Awesome post.

  19. SitNGo Wizard défini des modèles d’adversaire et propose
    de créer vos propres modèles personnalisés.

  20. We are a bunch of volunteers and starting a brand new scheme in our community.
    Your website offered us with valuable information to work on. You’ve performed
    a formidable process and our entire community will likely be
    grateful to you.

  21. We are a bunch of volunteers and starting a brand new scheme in our community.
    Your website offered us with valuable information to work on. You’ve performed
    a formidable process and our entire community will likely be
    grateful to you.

  22. The corporate’s working profit went up by 598% from SEK51.2 million in the corresponding interval final yr to SEK81.eight million this 12 months.

  23. Sure it has kettlebells and barbells, and all the usual things and exercises you see in most gyms.
    Also, distorted views of what ‘getting too big’ is exactly,
    are a worry. Do the study, learn the procedures and then let
    go a little, after all you are there because you want to do a skydive.

  24. Sure it has kettlebells and barbells, and all the usual things and exercises you see in most gyms.

  25. I think this is among the most significant info for me. And i am glad
    reading your article. But should remark on few general things, The website style is ideal,
    the articles is really nice : D. Good job, cheers

  26. It’s reɑlly a nice and useful piece of info. I am satisfied that you
    shared this useful informаtion with us. Please sfaү us informed like thiѕ.
    Thank yⲟս for sharing.

    Feel free too visit my ѕіte VT Bharadwaj (Casie)

  27. Jerry: Scientists in recent years have used sophisticated molecular biology technology to determine the good genes that turn on and the bad genes that turn off
    so that increases in the aging process can be observed.
    Off to dreamland laying not on a floor of pine needles to cushion us to sleep, but tree roots and rocks under the floor
    of the tent. com is still so new that all the information I want isn’t there yet.

  28. Awesome post.
    bhojpuri video song

  29. Awesome post.
    bhojpuri Video song

  30. It is more suited to on a regular basis use then the Travel Depot model,
    especially in case you are using it for one child.

  31. I’ve gone in like activating it again, may get yet another credit, but I’ve won this badge a number of occasions with the required
    wins but get no credit for badge.

  32. Considera-se, entretanto as divergências sexuais e a feminização da sociedade
    provando mudanças no cerne da formação familiar, do
    modo de vida, diante de aspectos tanto social como econômicos.

  33. Nevertheless, it is essential that a somewhat reduced larynx creation is learnt by the artist without exceedingly gloomy the
    larynx with all the origin of the language.

  34. Another element of me is grateful for the education I got
    at among the most effective universities in the world.

  35. It’s an amazing paragraph designed for all the online people; they will get benefit from
    it I am sure.

  36. Excellent site you have here but I was curious
    about if you knew of any forums that cover the same topics talked about in this article?
    I’d really love to be a part of online community where I can get responses from other knowledgeable people
    that share the same interest. If you have any suggestions, please let me know.
    Many thanks!

  37. A: Animosity is another feeling that you must keep an eye out for
    in your girlfriend.

  38. Thanks for a marvelous posting! I seriously
    enjoyed reading it, you may be a great author.
    I will make sure to bookmark your blog and definitely will come back later on. I
    want to encourage that you continue your great posts, have a nice evening!

  39. First of all I would like to say excellent
    blog! I had a quick question that I’d like to ask if you don’t mind.

    I was interested to find out how you center yourself and clear
    your head before writing. I’ve had difficulty clearing my thoughts in getting my
    thoughts out there. I do take pleasure in writing however it just seems like the first
    10 to 15 minutes are generally wasted just trying to figure out how to begin. Any ideas or hints?
    Appreciate it!

  40. sex

    Before considering an online dating agency, you should first
    read reviews about the site.

  41. Fever blister are caused by the herpes simplex infection type
    1, which the majority of people get through direct contact with somebody with the infection, such
    as through kissing or in person contact, or by sharing a contaminated personal item-a towel,
    razor or consuming utensil.

  42. I don’t know if it’s just me or if everyone else encountering problems with your website.
    It seems like some of the text in your content are running off the screen. Can somebody else please comment and let me
    know if this is happening to them too? This may be a
    issue with my web browser because I’ve had this happen previously.
    Cheers

  43. I searched online to know and ask about remedy
    for HERPES and i read somebody testimony on how he was treated
    from HSV-2 so i decided to call the same herbalist because i
    know that nature has the power to recover everything.

  44. sex

    To provide a broader context, study findings and recommendations are juxtaposed with myths and
    facts.

  45. This piece of writing gives clear idea in favor of the new people of
    blogging, that really how to do blogging and site-building.

  46. Sure it has kettlebells and barbells, and all the usual things and exercises you see in most gyms.
    Also, distorted views of what ‘getting too big’ is exactly,
    are a worry. Do the study, learn the procedures and then let
    go a little, after all you are there because you want to do a skydive.

  47. Hurrah, that’s what I was looking for, what a material!
    existing here at this webpage, thanks admin of this web site.

  48. Just desire to say your article is as astounding.
    The clarity in your post is simply spectacular and i could
    assume you are an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date
    with forthcoming post. Thanks a million and please carry on the rewarding
    work.

  49. I think that is one of the so much significant information for me.

    And i am glad studying your article. However want to remark on some common issues, The site style is great, the articles is in point of fact great
    : D. Excellent activity, cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>