HTML <pre> tagS2C Home   « HTML <pre> tag

Definition

The <pre> tag is used to define preformatted text.

Example


<pre>This text will be be displayed
  in a fixed width font and preserves whitespace
	and carriage returns.</pre>

Required Attributes

NONE

Optional Attributes

width deprecated - specifies the table width - use CSS instead.

Common Attributes

class - specifies a classname for the element allowing you to apply the style of the predefined class to the content.


<pre class="classname">Preformatted text here</pre>

id - specifies a unique id for the element allowing you to apply the style of the predefined id to the content.


<pre id="idname">Preformatted text here</pre>

style - specifies an inline style for the element allowing you to apply the style to the content.


<pre style="color:red;text-align:left">Preformatted text here</pre>

title - specifies extra information about the content.


<pre title="information about the content">Preformatted text here</pre>

Language Attributes

dir - specifies the directional flow of the content.


<!-- The text will flow from left to right -->
<pre dir="ltr">Preformatted text here</pre>

<!-- The text will flow from right to left -->
<pre dir="rtl">Preformatted text here</pre>

lang - specifies a language code for the content of the element.


<pre lang="en">Preformatted text here</pre>

xml:lang - specifies a language code for the content of the element in XHTML documents.


<pre xml:lang="fr">Preformatted text here</pre>

Document Event Attributes

NONE

Form Event Attributes

NONE

Image Event Attributes

NONE

Keyboard Event Attributes

onkeydown - The JavaScript code to be run when an element is in focus and keyboard key is pressed.


<!-- Executes the go() function -->
<pre onkeydown="go()">Preformatted text here</pre>

onkeypress - The JavaScript code to be run when an element is in focus and keyboard key is pressed down and released.


<!-- Executes the go() function -->
<pre onkeypress="go()">Preformatted text here</pre>

onkeyup - The JavaScript code to be run when an element is in focus and keyboard key is released.


<!-- Executes the go() function -->
<pre onkeyup="go()">Preformatted text here</pre>

Mouse Event Attributes

onclick - The JavaScript code to be run when a mouse is clicked on the element.


<!-- Executes the go() function -->
<pre onclick="go()">Preformatted text here</pre>

ondblclick - The JavaScript code to be run when a mouse is double clicked on the element.


<!-- Executes the go() function -->
<pre ondblclick="go()">Preformatted text here</pre>

onmousedown - The JavaScript code to be run when the mouse button is pressed down while the cursor is over the element.


<!-- Executes the go() function -->
<pre onmousedown="go()">Preformatted text here</pre>

onmousemove - The JavaScript code to be run when the mouse button is moved.


<!-- Executes the go() function -->
<pre onmousemove="go()">Preformatted text here</pre>

onmouseout - The JavaScript code to be run when the mouse cursor moves off an element.


<!-- Executes the go() function -->
<pre onmouseout="go()">Preformatted text here</pre>

onmouseover - The JavaScript code to be run when the mouse cursor moves over an element.


<!-- Executes the go() function -->
<pre onmouseover="go()">Preformatted text here</pre>

onmouseup - The JavaScript code to be run when the mouse button is released while the cursor is over the element.


<!-- Executes the go() function -->
<pre onmouseup="go()">Preformatted text here</pre>

go to home page Homepage go to top of page Top