Question

I have a div with a long text inside it that destroys my layout arrangement. Is there any way to split the words by any logic?

<div style="width:100px">thisdivmessesupmylayoutwithitslongchildtext</div>
Was it helpful?

Solution

Here's the way to do it:

<div style="width:100px;word-wrap:break-word">thisdivmessesupmylayoutwithitslongchildtext</div>

Using word-wrap: break-word; we can force the long word to move down a line when it reaches the parent width.

Note: word-wrap is a CSS3 property.

OTHER TIPS

set "width:auto" and "word-wrap:break-word"

this code will set the content in div as per the screen size..as contents in div reaches to right end of screen it will go to next line.

<div style="width:auto;word-wrap:break-word">thisdivmessesupmylayoutwithitslongchildtext</div>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top