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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Preformatted text in tables 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
How can I have preformatted text in a table and still have it wrap back instead of getting the horizontal scroll bar.

when I try using the PRE tag within the TD tag I get the preformatted text but the table resizes when the text is longer than width of the table.

It is imortant to know that I import the preformatted text so it is not possible to split it up per sentence and use the P tag.

Can someone help me please?
 
Can you not just specify the width of the cell. That way the text will automitcally wrap once the width is reached. Mise Le Meas,

Mighty :)
 
I opened the page below in a browser and it wraps the text no problem.

<HTML>
<BODY>
<TABLE BORDER=&quot;1&quot; WIDTH=&quot;100%&quot;>
<TR>
<TD WIDTH=&quot;100&quot;>THIS IS JUST A TEST TO SEE IF THE CELL WILL WRAP THE TEXT.</TD>
<TD>THIS IS JUST A TEST TO SEE IF THE CELL WILL WRAP THE TEXT.(The width of this cell is not restricted.)</TD>
</TR>
</TABLE>
</BODY>
</HTML> Mise Le Meas,

Mighty :)
 
I rediscovered a little tag that I forgot about
pretty neat use:
it will force yout text to auto adapt to any win size

type it as:
<nobr><wbr>etc..etc..etc..</wbr></nobr>

also if you use CSS and SSI you should add consistency in design.

good luck
 
To Mighty,

Correct, BUT if you add the <PRE> tags this is no longer the case.

<HTML>
<BODY>
<TABLE BORDER=&quot;1&quot; WIDTH=&quot;100%&quot;>
<TR>
<TD WIDTH=&quot;100&quot;><PRE>THIS IS JUST A TEST TO SEE IF THE CELL WILL WRAP THE TEXT.</PRE></TD>
<TD>THIS IS JUST A TEST TO SEE IF THE CELL WILL WRAP THE TEXT.(The width of this cell is not restricted.)</TD>
</TR>
</TABLE>
</BODY>
</HTML>
 
Isn't there anyone who can help me with this??

Actually this problem doen't only occur in tables but also in the body.

Isn't there a tag that will allow to display preformated text but will still wrap around long sentences?
 
The only way I know of that you could get it to wrap would be to put <textarea> and </textarea> tags around the preformatted text. Then you could use css to take the border off and make it look like normal text. This would work pretty good, except it would show the html tags within the <textarea>. So instead of:
THIS IS JUST A TEST TO SEE IF THE CELL WILL WRAP THE TEXT.
You would get:
<pre>THIS IS JUST A TEST TO SEE IF THE CELL WILL WRAP THE TEXT.</pre>

And I really doubt you'd want it to do that.

Is the preformatted text way too big for the table it is in? If not, you might be able to mess with fonts and font sizes to get it to fit...

Basically, I think you're SOL on this. If I were you I would try to change the way you're getting the text or edit the source of the text. I think that's probably the only good way to fix this...
 
The only thing that would come close would be to use the <blockquote> tag.

It will maintain formating but cut at the table margin.

HOpe this helped.
 
Hi

I had this exact same problem. I eventually found two solutions that both worked for me.

The first is to use a TEXTAREA to display the text, then use a CSS to make it read-only and remove the scroll bar and border. The text wraps successfully them whilst maintaining paragraphs.

The second is to make your page into an Active Server Page. Transfer your text into a variable (in the example below it's called &quot;MyText&quot;). Then use the VBScript below to replace all carraige-returns and line feeds with <br>.

MyText = Replace(MyText, vbCrLf, &quot;<br>&quot;)

Then you can just display the &quot;MyText&quot; variable. It really works!!

Hope these help.

Cheers
Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top