12

I have the following code:

.thing {
  width: 90%;
  height: 400px;
  border: 10px solid #000;
}
<div class="thing">
  aaaaaaaaaaaa
</div>

The problem is that when I add to much content, the text goes out of the div!

How to fix this using only CSS?

YJM
  • 133
  • 1
  • 2
  • 11
Luis Parker
  • 131
  • 2
  • 2
  • 8

2 Answers2

14
.thing {
width: 90%;
height: 400px;
padding: 10px solid #000;
word-break:break-all;
}

use word-break

Bhushan Kawadkar
  • 28,279
  • 5
  • 35
  • 57
  • What is the difference between breakall and breakword? – Luis Parker Jun 11 '13 at 16:43
  • break-all will move your word to next line if it does not fit into container width but break-word will break the word to make it fit into container width. see this link http://stackoverflow.com/questions/1795109/what-is-the-difference-between-word-break-break-all-versus-word-wrap-break – Bhushan Kawadkar Jun 12 '13 at 11:02
4

this happen coze you are not adding space

just add a space some where between 'aa' like this > 'aaaaaa aaaaaa' there is not word with 12 character

but if you need this long word then use

word-break:break-all;
fahd4007
  • 544
  • 4
  • 14