tags:

views:

1147

answers:

3

Is there a word-wrap or any other attribute that stops text from wrapping? I have a height, and overflow:hidden, and the text still breaks.

Needs to work in all browsers, in before CSS3.

+1  A: 

Sometimes using ' ' instead of a spaces will work. Clearly it has drawbacks, though.

grossvogel
Unfortunately, I can't do it in this circumstance
+9  A: 
<div>test that doesn't wrap</div>

<style type="text/css">
div {
  white-space: nowrap;
  overflow: hidden;
}
</style>

Note: this only works on block elements. If you need to do this to table cells (for example) you need to put a div inside the table cell as table cells have display table-cell not block.

cletus
white-space! That's what I've been looking for... 1,000 thanks... this is impossible to google for!
There is also a proprietary ie attribute called word-wrap (IIRC)... stupid IE.
garrow
+1  A: 

white-space: nowrap

Robert C. Barth