Text not wrapping inside a div element

125,370

Solution 1

That's because there are no spaces in that long string so it has to break out of its container. Add word-break:break-all; to your .title rules to force a break.

#calendar_container > #events_container > .event_block > .title {
    width:400px;
    font-size:12px;
    word-break:break-all;
}

jsFiddle example

Solution 2

I found this helped where my words were breaking part way through the word in a WooThemes Testimonial plugin.

.testimonials-text {
    white-space: normal;
}

play with it here http://nortronics.com.au/recomendations/

<blockquote class="testimonials-text" itemprop="reviewBody">

<a href="http://www.jacobs.com/" class="avatar-link">

<img width="100" height="100" src="http://nortronics.com.au/wp-content/uploads/2015/11/SKM-100x100.jpg" class="avatar wp-post-image" alt="SKM Sinclair Knight Merz">

</a>
<p>Tim continues to provide high-level technical applications advice and support for a very challenging IP video application. He has shown he will go the extra mile to ensure all avenues are explored to identify an innovative and practical solution.<br>Tim manages to do this with a very helpful and professional attitude which is much appreciated.
</p>
</blockquote>

Solution 3

The problem in the jsfiddle is that your dummy text is all one word. If you use your lorem ipsum given in the question, then the text wraps fine.

If you want large words to be broken mid-word and wrap around, add this to your .title css:

word-wrap: break-word;

Solution 4

This may help a small percentage of people still scratching their heads. Text copied from clipboard into VSCode may have an invisible hard space character preventing wrapping. Check it with HTML inspector

string with hard spaces

Solution 5

you can add this line: word-break:break-all; to your CSS-code

Share:
125,370
Vasileios Tsakalis
Author by

Vasileios Tsakalis

Updated on July 08, 2022

Comments

  • Vasileios Tsakalis
    Vasileios Tsakalis almost 2 years

    I am experiencing a problem that never happened before and seems really unprecedented, some text is not wrapping inside a div.

    In this link is a sample of my html code:

    http://jsfiddle.net/NDND2/2/

    <div id="calendar_container">
       <div id="events_container">  
          <div class="event_block">
             <div class="title">
                lorem ipsum lorem ipsumlorem ipsumlorem ipsumlorem
             </div>
          </div>
       </div>
    </div>
    

    Any help??