You are here: Re: WIDTH attribute for peformatted text « HTML « IT news, forums, messages
Re: WIDTH attribute for peformatted text

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация