pre ElementThe pre element is a block-level element declared by the XHTML 1.1 Text Module (Block Phrasal)
Elements in the Text Module are:span | br (Inline Structural Support Module)em | strong | q | cite | abbr | acronym | code | var | kbd | samp | dfn (Inline Phrasal Support Module)div | p (Block Structural Support Module)h1 - h6 | blockquote | pre | address (Block Phrasal Support Module)
The pre element is a handy container element for text when you want to preserve its whitespace and hence layout (e.g. for
program code or poetry). This is in contrast to the default behaviour of other elements, which is to contract all stretches of
whitespace to a single space. pre output is usually rendered in a monospace font.
For example:
<pre>Text formatted with whitespace
as it appears
in the file and usually
formatted
in a monospace
font
to ensure the correct alignment.</pre>
This renders as follows:
Text formatted with whitespace
as it appears
in the file and usually
formatted
in a monospace
font
to ensure the correct alignment.
The pre element is a block element and so its contents begin on a new line.
The effect of the pre element may be achieved on another block level element by
using the CSS declarations
white-space:pre;font-family:monospace but bear in mind that
not all users will have author styles enabled.
For detailed information on CSS whitespace processing see: *CSS 2.1 - Whitespace: the 'white-space' property.
There are no #REQUIRED attributes on the pre element.
There are no specific attributes declared on the pre element.
pre element are listed below:class [ type NMTOKENS ]id [ type ID ]style [ type CDATA ], from the Style Attribute Module (deprecated)title [ type Text ]xmlns [ type URI - #FIXED 'http://www.w3.org/1999/xhtml' ]dir [ type Enumeration (ltr | rtl) ], from the Bi-directional Text Modulexml:lang [ type LanguageCode ]All attributes in the
Events Attribute Collection
are supported:onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
pre element is:
( #PCDATA | InlStruct.class | InlPhras.class | I18n.class | Anchor.class | tt | i | b | script | map )*
See Content Model & Nesting for information about Content Model syntax and Nesting Groups.
preabbr, acronym, br, cite, code, dfn, em, kbd, q, samp, span, strong, varab, i, ttmapscriptbdoNote:
A pre element must never contain any of the following elements, at any nesting depth:
img, object, big, small, sub, sup.
See Descendant Exclusions.
prebodyblockquote, divdd, litd, thbutton, fieldset, formmapnoscriptdel, insobject