[thelist] apply PRE formatting with css?

James Aylard jaylard at encompass.net
Fri Aug 31 00:35:50 CDT 2001


Nate,

> i was wondering if there was a way to achieve this:
> <div><pre>
> 	source code
> </pre></div>
> without the <pre> tags. in other words, can I apply "pre" formatting by
> using CSS? I'm tyring to find the best way to display source code on a

	You can use CSS in place of the <pre> element:

<style type="text/css">
  <!--
    div
    {
      white-space: pre ;
    }
  -->
</style>

	Keep in mind that this works in IE 6 and Netscape 6, but not previous
versions. And, as aardvark suggested earlier, the <code> element might be a
better choice because its purpose is to mark-up content intended to display
as code samples.

James Aylard





More information about the thelist mailing list