This container tag is used to enclose pre-formatted text. Within the tag all spaces are rendered literally and line breaks are rendered literally, however HTML markup is still recognised so if, for example, it is required to include a less than sign within <pre> ... </pre> it is necessary to write it as < This means that it is not possible to, for example. simply cut and paste a program listing into a <pre> ... </pre> block. The effect of font size changing tags and <img> tags within a <pre> ... </pre> block is not totally certain, the HTML 3.2 standard suggests that they should be ignored.
Text will be rendered using a monopitch typeface. The <pre> tag implies a paragraph break, i.e. end the current line and generate a blank line.
Also within <pre> ... </pre> long lines are no longer wrapped, they simple disappear out of the right hand side of the browser window although the browser horizontal scroll bar will usually reveal the text. The HTML 3.2 suggests but does not bless the fact that some browsers allow a width attribute to control the point at which line wrapping starts.
Here's a simple example of the use of <pre>
This is preformatted text. There are 4 spaces at the start of this line A short line A blank line above
Here's the HTML
<pre> This is preformatted text. There are 4 spaces at the start of this line A short line A blank line above </pre>
And now for a long line to show the width attribute
This is a rather long line with the width attriubte set to a fairly low value (40) to see what happens.
Browsers
All browsers honour this tag in the same fashion.
No browser tested seemed to honour the width attribute.
All browsers were happy to allow text style mark up and
the use of an <img> tag within a <pre> container.