Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable word wrap

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
GB
Is it possible to disable word wrap for lines within a <div> element so that, unless a <br> is included, the line will just get truncated at the edge of the element rather than flow automatically to the next line?

Thanks in advance.
 
Hmm, on further investigation, it appears that the <pre> tag will achieve close to what I am after but is there any way of stopping it from switching to a monospace font (Courier)?
 
On second thoughts, <pre> would appear to be a thing of the past. An alternative approach is to substitute spaces with &nbsp; in any text which should appear unbroken. Also, this approach doesn't mess with the font.
 
use a no break tag <nobr>text that won't wrap</nobr>
 
Thanks but is that supported by all browsers? This link:


seems to suggest only Netscape and the book I have suggests it is "Nonstandard" and that the "HTML 4.01 specification prefers style sheets for preventing line breaks" though I'm not sure how I'd use a style sheet in this situation.
 
Ahah - { white-space: nowrap } would appear to be the CSS approach.
 
<nobr> works in IE 5.5+ and FF.</nobr>

I don't know the compatibility of {white-space:nowrap}, but i'd prefer that method.
 
Thanks again - I've gone for the {white-space:nowrap} option and it seems to work fine for IE. Finding it was the hard part!

Have yet to test in FF.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top