The PRE element indicates text that has been formatted for the
screen and is rendered using a fixed-width font. All characters are
interpreted literally and retained in display, including multiple spaces,
tabs, carriage returns and linefeeds (all other cases of HTML collapse
multiple spaces, tabs, CRs, or linefeeds to a single space.)
Description:
This attribute specifies the maximum number of characters for a line
and allows the browser to select a suitable font and indentation.
Values of 40, 80 and
132 characters should be presented optimally,
with other widths being rounded up.
DTD Note: The HTML specifications have always gone
out of their way to exclude objects and size modifying markup from
PRE content. HTML 4.0 continues this trend, but does not exclude
the IFRAME element. This seems odd since other objects like IMG, APPLET
and OBJECT ARE excluded.
DTD Note: I excluded the NOBR and BLINK elements,
from the PRE content model. These elements are very similar to other
excluded physical markup in the HTML 4.0 DTD.
The HTML 3.2 specification lists support for the WIDTH attribute.
The specification at one time had a note by this attribute asking:
"Does anyone support this?". Of the Reviewed
browsers, none do.
Application of styles in PRE should not have any effect on the
preservation of spaces.
Spaces
All spaces should be preserved.
Tabs
"The horizontal tab character (code position 9 in the HTML
document character set) must be interpreted as the smallest positive
nonzero number of spaces which will leave the number of characters so
far on the line as a multiple of 8. Documents should not contain tab
characters as they are not supported consistently." With this
caveat, it is easy to see that the behavior of tabs may be VERY
inconsistent from browser to browser.
Linefeeds and Carriage Returns
There are different forms of linefeeds and carriage returns used on
different operating systems. All of them should be preserved.
Browser Peculiarities
Parent/content behavior of this element may be very browser-dependent.