Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off word wrapping in HTML?

I feel silly for not being able to figure this out, but how do I turn off wordwrap? the css word-wrap property can be forced on with break-word, but cannot be forced off (only can be left alone with normal value).

How do I force word wrap off?

like image 635
Alexander Bird Avatar asked Jan 10 '11 23:01

Alexander Bird


People also ask

How do I make text not wrap around an image in HTML?

You'll have to wrap your text in its own container. Since your <img> is floated to the left, you can use overflow: hidden on your newly-added container to achieve no wrapping of the text.

Which tag is used to turn off the word wrapping?

Use the &nbsp; entity for the non-breaking space character, when you want to make sure that a line isn't broken! Alternatively, use the NOWRAP attribute to disable word wrapping and the <BR> element to force line breaks where desired. Netscape includes two tags: <NOBR>... </NOBR>, and <WBR>.


2 Answers

You need to use the CSS white-space attribute.

In particular, white-space: nowrap and white-space: pre are the most commonly used values. The first one seems to be what you 're after.

like image 136
Jon Avatar answered Sep 19 '22 05:09

Jon


Added webkit specific values missing from above

white-space: -moz-pre-wrap; /* Firefox */ white-space: -o-pre-wrap; /* Opera */ white-space: pre-wrap; /* Chrome */ word-wrap: break-word; /* IE */ 
like image 45
Matas Vaitkevicius Avatar answered Sep 23 '22 05:09

Matas Vaitkevicius