0

Possible Duplicate:
wordwrap a very long string

My code

<div style="width:40px;">adfdddddddddddddddddddd</div>

This code should make 4 lines but it is displaying the output in one line.

Community
  • 1
  • 1

3 Answers3

5

Try

<div style="width:40px;word-wrap:break-word;">adfdddddddddddddddddddd</div>;
jenson-button-event
  • 18,101
  • 11
  • 89
  • 155
2

For word wrap consider adding this class.

.wordwrap { 
   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;      /* IE */
}

See the reference here Is there a way to word-wrap long words in a div?

Community
  • 1
  • 1
Subir Kumar Sao
  • 8,171
  • 3
  • 26
  • 47
1

Your code is showing the output in one line because it's taking the content as a single word. A single word will be shown in a single line. Try this code using some sentence then you will get the desired output. You can try something like the following

<div style="width:40px;">This is a sentence.</div>