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

How to get proper wrapping 1

Status
Not open for further replies.

theScien

Technical User
Aug 27, 2003
98
PT
My web site is a fixed width style container, and I have problems displaying information that exceeds the maximum allowed width for my web site, all graphics go bananas, I understand why, so I'm looking for a wrapping solution to get those long sentences to wrap automatically.

I can hear some of you saying, that it is done already, but not when I use the <PRE> tag to display the content as it was inputed.

Is there anyway to achieve this with the <PRE> tag?

Thanks.

If you haven't heard of it, then you most likely don't need it.
---------------------------------------------------------------------
---------------------------------------------------------------------
 
you could use the <PRE> tag inside a table of fixed length
 
The table won't make any difference - the browser will stretch the table to accommodate the <pre> text.

I don't think you can do this. The whole point about the <pre> tag is that it says to the browser &quot;This is my pre-formatted text. Don't mess with it!&quot;. All the things browsers usually do, like closing up white space and wrapping long lines, don't happen to the contents of a <pre>.

-- Chris Hunt
 
Yep, also arrived at the same conclusion the PRE realy comes on top of everything else, unless, I'm guessing, I could define a class for the PRE with a predefined width..

What should be the CSS for that?

If you haven't heard of it, then you most likely don't need it.
---------------------------------------------------------------------
---------------------------------------------------------------------
 
<pre style=&quot;width:200px; overflow:auto&quot;>
...
</pre>

obviously change the width to suit your needs

on error goto hell
 
Set your table cell widths to a fixed pixel value and don't use any &quot;wrapping&quot; tags. The text will automatically wrap within the cells.

There's always a better way. The fun is trying to find it!
 
Will try Sashi's suggestion as for just setting the cell width, it won't work, remember I have to use the <PRE> tage so the content is shown as it was inputed, so cell widths will be completely ignored.

Please keep those suggestions flowing, there's got to be an abscure way to accomplish this.

If you haven't heard of it, then you most likely don't need it.
---------------------------------------------------------------------
---------------------------------------------------------------------
 
SashiRaveendran's tip is a pretty good solution. The scrollbars won't appear except in the cases where the lines are too long, otherwise it will look normal. You can also add &quot;font:normal 8pt sans-serif&quot; to the style to get the text to shrink a little.

petey

News and views of some obscure guy
 
if you put a width on the cell and the pre is a child of the cell then the pre shouls stretch to the width of the cell. If the content in the pre gets any larger than the width of the cell then the scrollbars will appear.

on error goto hell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top