TAG:  pre

<pre> ... </pre>
 
The pre tag is used to display pre-formatted text. The output will mimic exactly how the text is rendered inside the pre element including white space, tabs, and line breaks. This allows you to maintain the appearance of data in rows and columns, or have extra white spaces in text such as poems. Perhaps one of the most common uses of this tag is to display computer code and output.
 
The browser will display the text in a mono spaced font. However, you can use style sheets, including the style attribute, to effect the appearance of the text to suit your desires.
 
The following tags may not appear inside a pre element: big, img, object, small, sub, and sup. Therefore, images, which require an img tag, cannot appear in a pre.
 
The separate closing tag is mandatory.
 
Attributes and Events
 
class    dir    id    lang    onclick    ondblclick    onkeydown    onkeypress    onkeyup    onmousedown    onmousemove    onmouseout    onmouseover    onmouseup    style    title
 
The example is shown twice, with and without the use of style sheets. (Note that HTML does not show the extra white spaces that are present in the code.)
 
Code without style:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML pre Tag Example</title>
</head>
<body>
<pre>
function CheckFrames()
{
var strPage, strURL
strPage = location.pathname + location.search
strURL = location.protocol + "//" + location.hostname +
"/index.asp?page=" + escape(strPage)

if ((window.name != "body") || (window.parent.name != "frameset") ||
(window.parent.parent.parent != window.parent.parent))
{
window.top.location.replace(strURL)
}
}
</pre>
</body>
</html>


Code with style:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML pre Tag Example</title>
</head>
<body>
<pre style="font-family:arial; color:purple; font-size:12px;">
function CheckFrames()
{
var strPage, strURL
strPage = location.pathname + location.search
strURL = location.protocol + "//" + location.hostname +
"/index.asp?page=" + escape(strPage)

if ((window.name != "body") || (window.parent.name != "frameset") ||
(window.parent.parent.parent != window.parent.parent))
{
window.top.location.replace(strURL)
}
}
</pre>
</body>
</html>

 
Output without style:
 
function CheckFrames()
{	
	var strPage, strURL
	strPage = location.pathname + location.search
	strURL = location.protocol + "//" + location.hostname +
			"/index.asp?page=" + escape(strPage)

	if ((window.name != "body") || (window.parent.name != "frameset") ||
		(window.parent.parent.parent != window.parent.parent))
	{
		window.top.location.replace(strURL)
	}
}    	
Output with style:
function CheckFrames()
{	
	var strPage, strURL
	strPage = location.pathname + location.search
	strURL = location.protocol + "//" + location.hostname +
			"/index.asp?page=" + escape(strPage)

	if ((window.name != "body") || (window.parent.name != "frameset") ||
		(window.parent.parent.parent != window.parent.parent))
	{
		window.top.location.replace(strURL)
	}
}


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information