3

I have a div but when the text inside it is too long, it will wrap and make the div multiple lines. This makes the page bad. How can I avoid text in a div not wrap?

Bin Chen
  • 61,507
  • 53
  • 142
  • 183

2 Answers2

4

There is a reason the test is wrapping. But if you don't care for then then you set the overflow style to visible and set the style="white-space: nowrap;" style as well

Shiv Kumar
  • 9,599
  • 2
  • 36
  • 38
1

The answer depends on the desired result. If you MUST keep the div fixed size, sacrificing some of the visible text that doesn't fit, use width, height and overflow: hidden, otherwise you use white-space: nowrap as already suggested.

Dennis Kreminsky
  • 2,117
  • 15
  • 23