Warning:
This wiki has been archived and is now read-only.
Elements/pre
From HTML Wiki
< Elements
Contents
<pre>
The <pre> element represents a block of preformatted text.
Point
- Some examples of cases:
- computer code
- ASCII art...
- This element is used with the code element, the samp element, or the kbd element, and so on, according to the kind of content inside a pre element. [Example B]
- The author should consider accessibility, when use the pre element. This is because, when speech synthesizers, braille displays, and the like is used, there is a possibility that preformatted text is destroyed. For exapmle, For cases like ASCII art, it is likely that an alternative presentation, such as a textual description, would be more universally accessible to the readers of the document.
HTML Attributes
See global attributes.
Examples
Example A
[try it]
<pre>
Line 1.
Line 2 is to the right of line 1.
Line 3 aligns with line 2.
</pre>
Example B
With the code element [try it]:
<pre>
<code>
function Panel(element, canClose, closeHandler) {
this.element = element;
this.canClose = canClose;
this.closeHandler = function () { if (closeHandler) closeHandler() };
}
</code>
</pre>
HTML Reference
The HTML5 specification defines the <pre> element in 4.5.3 The pre element.