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.


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.


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.


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.


  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

  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.

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>