Click to See Complete Forum and Search --> : How to write text without wrapping


Caliban
07-10-2003, 03:47 PM
Hi y'all JS gurues!

Is there any posibility to do this:
I write a text with length 80+

i.e. (pls copy and paste this piece of code, and you'll see)

<HTML>
<FONT FACE="Courier" SIZE = 2>
123456789'123456789'123456789'123456789'123456789'123456789'123456789'123456789'123456789'123456789' 123456789'123456789'
MY LONG NAME-----------------------------------------------------64.263.300------------64.263.300------------64.263.300
</FONT>
</HTML>

I don't know why the numeric line is written without wrapping, while the text line is not (the characters after pos.87 are being wrapped to the next line)

I need both lines to be written without wrapping.

Any suggestion? This could be probably a HTML issue instead of JS issue ... (?)

Thanx In Advance.

freefall
07-10-2003, 03:57 PM
<HTML>
<FONT FACE="Courier" SIZE = 5>
<pre>
123456789'123456789'123456789'123456789'123456789'123456789'123456789'123456789'123456789'123456789' 123456789'123456789'
MY LONG NAME-----------------------------------------------------64.263.300------------64.263.300------------64.263.300
</pre>
</FONT>
</HTML>


The <pre> will write it however you format it in your editor, returns, tabs, etc.

- Ian

David Harrison
07-10-2003, 03:57 PM
If you know what you're going to write and therefore how long the line will be, then you could have this:

<div width="x">Some content</div>

Jona
07-10-2003, 04:16 PM
There is the <nobr>Long string of text</nobr> tag, if you mean that. Or, there is just simple entities that allow you to do more than one space in a row. Example, if you put [space][space] the result will appear as one [space]. So instead, you use [space]&amp;nbsp; which will result in [space][space] being visible in the document.

Two spaces:

_ _

A space and an ASCII entity:

_ &nbsp;_

[J]ona

David Harrison
07-10-2003, 04:19 PM
I was thinking of suggesting the nobr tag but I think it only works with Netscape and IE.

Jona
07-10-2003, 04:21 PM
Originally posted by lavalamp
I was thinking of suggesting the nobr tag but I think it only works with Netscape and IE.

You're right, it shouldn't be used. I can't seem to find it in the HTML 4.01 Recommendation.

[J]ona

freefall
07-10-2003, 04:32 PM
Is <pre> bad to use, I mean would you recommend it? I've never used it, but it works for this problem, and it can be any font. Lemme see... it's defined in HTML 3.2 and the W3C DOM

- Ian

Jona
07-10-2003, 04:38 PM
Originally posted by freefall
Is <pre> bad to use, I mean would you recommend it? I've never used it, but it works for this problem, and it can be any font. Lemme see... it's defined in HTML 3.2 and the W3C DOM

Yes, I'd recommend it. Using element such as <xmp> work but are depreacated--<pre> is not.

[J]ona

Caliban
07-10-2003, 04:54 PM
Hi y'all, JS gurues!

Finally, I used the "<PRE></PRE>" tag

Even I used to create a variable, like this
newElem = document.createElement("pre");

... and everything worked fine.


By the way, I built a tree-generator, using no tables but text only; I just needed something like "<PRE>" to finalize it. The tree is generated in this way:

1) A table is built, with the content of the tree
2) The table is read in order to build the tree
3) The tree is shown

If anyone is interested ...



Thanx everybody for your interest in this issue. I think everybody here is a guru except me :)