How to turn off Word Wrap?

  • Thread starter Dan Christensen
  • Start date
D

Dan Christensen

Can I turn off the word wrap feature in an HTML document? I would like to
have long lines of plain text that may go off the page, breaking only where
I want, with horizontal scroll bars when necessary.

Dan
 
S

Sean

Can I turn off the word wrap feature in an HTML document? I would like
to have long lines of plain text that may go off the page, breaking
only where I want, with horizontal scroll bars when necessary.

Dan


If its just plain text, you could use the <pre></pre> tag which will output
text "as is", or perhaps use CSS like this:

<p style="white-space:pre;">
...
</p>

umm, not sure if all browsers support that CSS property, tho.
 
D

Disco

Dan said:
Can I turn off the word wrap feature in an HTML document? I would
like to have long lines of plain text that may go off the page,
breaking only where I want, with horizontal scroll bars when
necessary.

Dan

wasn't there something like....

white-space:nowrap;

????
 
S

Sid Ismail

: Can I turn off the word wrap feature in an HTML document? I would like to
: have long lines of plain text that may go off the page, breaking only where
: I want, with horizontal scroll bars when necessary.


Use "pre"

Sid
 
D

Dan Christensen

Jukka K. Korpela said:
The answer is definitely "maybe", as usual. (That is, some methods work
some of the time, and that's largely how things are _meant_ to be.)
For this reason, and for other reasons, it is essential _why_ you would
like to do that.


That would be <pre>, if you use HTML for the purpose, but why do you wish
to create horizontal scrolling - it's normally a problem to be avoided?

To show examples of code which may be indented several levels and often goes
off the page.

Thanks everyone! The <pre> tag looks promising.

Dan
 
J

Jukka K. Korpela

Dan Christensen said:
To show examples of code which may be indented several levels and
often goes off the page.

Then <pre> is probably the best shot. Logically you should _also_ use
<code> if it is code, but this has no effect on default rendering.

You could consider reducing slightly the font size, to make it more
probable that the content fits without scrolling. For example, with the
following style sheet:

pre { font-family: "Courier New"; font-size: 70%; }

(Reducing font size by 30% is rather extreme, but probably still works
reasonably in most situations.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top