wrapping <pre>

liunx

Guest
Does anyone know of a way of wrapping <pre> formatted text in modern browsers. The <pre width="80"> is not working in IE6, putting it inside a table with a specific width does not work. Anyone?<br />
<br />
I have to use <pre> for a partcular part of a page, there is no way around it :(<br />
<br />
/Porsche<!--content-->The <pre width="80"> is not working in IE6, putting it inside a table with a specific width does not work. Anyone?<br />
why doesn't it work anymore? it hasn't changed and yes you can still use tables.<br />
<br />
what is the code in question?<!--content-->Apologies, I wasn't clear... it has never worked previously, I only started it this morning.<br />
<br />
The data that is preformatted is in a database, so my code is:<br />
<%<br />
response.write("<table width=500 border=0><tr><td><pre>"& blah &"</pre></td></td></table>")<br />
<br />
%><br />
<br />
Where blah is the string from the database.<br />
<br />
/Porsche<!--content-->well accoring to that it will be at width of 500 and in a table. that all looks correct. but the 2 closing "td" do not. it won't stop IE from running the code but it is a little messy.<br />
<br />
turn your borders on so you can see what is happening. is the table in the correct spot? does your "blah" text getting into that table?<br />
<br />
do you have a test url?<!--content-->The double </td> was a typo before, I was remote controlling the PC that I was working on and couldn't cut'n'paste. <br />
<br />
I'm back at my desk now so:<br />
test page=<br />
<!-- m --><a class="postlink" href="http://www.c-sap.bham.ac.uk/projects/findings/test.asp">http://www.c-sap.bham.ac.uk/projects/findings/test.asp</a><!-- m --><br />
<br />
Code from test page:<br />
<br />
<p>With pre tag in a table 475px wide:</p><br />
<%<br />
response.write("<table width=475 border=1><tr><td><pre width=80>"& summary &"</pre></td></tr></table>")<br />
%><br />
<p>With no pre tag in a table 475px wide:<br />
<%<br />
response.write("<table width=475 border=1><tr><td><p>"& summary &"</p></td></tr></table>")<br />
%><br />
<br />
As you can see the table is the correct size, but the pre tags make it extend past its fixed width :(<br />
<br />
I'm thinking that I'm going to have to write something to break the strings correctly or even asc() each character and look for cr/lf. :(<br />
<br />
/Porsche<!--content-->I've found that scrapping <pre> and instead using:<br />
<br />
summary=replace(summary,VbCrLf,"<BR>") <br />
<br />
Solves my problem.<br />
<br />
thanks for the advice<br />
<br />
/Porsche<!--content-->actually that first table is correct. that is what the pre tag does, shows the text how it is, you have to manually enter the paragraph breaks in order to get the correct line breakage.<br />
<br />
it was working correctly just not how you wanted.<br />
<br />
glad you got it to work. :)<!--content-->Sure, but the width=80 attribute should have limited it to 80 characters, right?<br />
<br />
/Porsche<!--content-->I don't beleive so as that would make the pre tag not a pre tag. by definition it is a tag for preformatted stuff so it shows it how it is. if you limit it then it might not work as expected. which you found out.<br />
<br />
actually width=80 has nothing to do with how many characters it will hold, that number is in pixels, not all font is a letter a pixel.<!--content-->I think the 'width' attribute which I was trying to use is non-functional in IE6 for reasons which you state (makes sense really).<br />
<br />
Quote from <!-- m --><a class="postlink" href="http://www.w3.org/TR/html4/struct/text.html#edef-PRE">http://www.w3.org/TR/html4/struct/text.html#edef-PRE</a><!-- m --><br />
width = number [CN] <br />
Deprecated. This attribute provides a hint to visual user agents about the desired width of the formatted block. The user agent can use this information to select an appropriate font size or to indent the content appropriately. The desired width is expressed in number of characters. This attribute is not widely supported currently.<br />
<br />
/Porsche<!--content-->well there you go. I don't use width in a pre tag so I was wrong on saying it was a width and not characters. makes sense :)<!--content-->
 
Back
Top