|
Posted by Toby Inkster on 10/01/05 16:56
Jud McCranie wrote:
> OK, then what is the best way to have fixed-width text, with a
> parameter telling the width of the line (so the browser can adjust the
> size to get wide lines all on the screen)?
You could use CSS 2.1's "white-space:pre-wrap" which basically means
"treat this like <pre>, but wrap lines if it's really needed".
<pre style="white-space:pre-wrap">
Blah. Preformatted text goes here. Blah.
</pre>
Downside is that it doesn't work in Internet Explorer.
Alternatively, you could use PHP's wordwrap() function:
<? ob_start(); ?>
Blah. Preformatted text goes here. Blah.
<?
$x = ob_get_contents();
ob_end_clean();
printf ("<pre>%s</pre>\n", wordwrap($x,76));
?>
Downside there is that the width is fixed at 76 characters, which may or
may not be appropriate for the visitor's browser width.
--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Now Playing ~ ./andreas_johnson/liebling/05_should_have_been_me.ogg
Navigation:
[Reply to this message]
|