1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html lang=en>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>PRE - Preformatted Text</title>
<link rev=Made href="mailto:liam@htmlhelp.com">
<link rel=Start href="../index.html">
<link rel=StyleSheet href="../style.css" type="text/css">
<link rel=StyleSheet href="../aural.css" type="text/css" media=aural>
<link rel="Alternate StyleSheet" href="../strictHTMLonly.css" type="text/css" title="Strict HTML only">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta name="author" content="Liam Quinn">
<meta name="description" content="A description of HTML 4.0's PRE element for preformatted text.">
<meta name="keywords" content="PRE, pre element, preformatted text, HyperText Markup Language, HTML, HTML4, HTML 4.0, Web Design Group, WDG, <pre> tag, <PRE> tag">
<script type="text/javascript">
<!--
function toggle() {
if (document.all.toggler.value == "Hide non-strict elements and attributes") {
document.styleSheets[0].addRule("div.transitional", "display:none");
document.styleSheets[0].addRule("span.transitional", "display:none");
document.styleSheets[0].addRule("li.transitional", "display:none");
document.styleSheets[0].addRule(".transitional", "speak:none");
document.all.toggler.value = "Show non-strict elements and attributes";
} else {
document.styleSheets[0].addRule("div.transitional", "display:block");
document.styleSheets[0].addRule("span.transitional", "display:inline");
document.styleSheets[0].addRule("li.transitional", "display:list-item");
document.styleSheets[0].addRule(".transitional", "speak:inherit");
document.all.toggler.value = "Hide non-strict elements and attributes";
}
}
// -->
</script>
</head>
<body>
<h2><img src="../wdglogo1.gif" width=250 height=83 alt="The Web Design Group"></h2>
<h1>PRE - Preformatted Text</h1>
<script type="text/javascript">
<!--
if (document.styleSheets && document.all) {
var gt;
gt = unescape(new String("%3E"));
document.write("<p" + gt + "<input type=button value=\"Hide non-strict elements and attributes\" id=toggler accesskey=s onclick=\"toggle()\"" + gt + "<\/p" + gt);
}
// -->
</script>
<table>
<tr valign=top>
<th>Syntax</th>
<td><strong class=required><PRE></strong>...<strong class=required></PRE></strong></td>
</tr>
<tr valign=top>
<th>Attribute Specifications</th>
<td>
<ul>
<li class=transitional>WIDTH=<var><a href="../values.html#number">Number</a></var> (line width)</li>
<li><a href="../attrs.html">common attributes</a></li>
</ul>
</td>
</tr>
<tr valign=top>
<th>Contents</th>
<td><a href="../inline.html">Inline elements</a> except <a href="../special/img.html">IMG</a>, <a href="../special/object.html">OBJECT</a>, <span class=transitional><a href="../special/applet.html">APPLET</a>, </span><a href="../fontstyle/big.html">BIG</a>, <a href="../fontstyle/small.html">SMALL</a>, <a href="../special/sub.html">SUB</a>, <a href="../special/sup.html">SUP</a><span class=traditional>, <a href="../special/font.html">FONT</a>, <a href="../special/basefont.html">BASEFONT</a></span></td>
</tr>
<tr valign=top>
<th>Contained in</th>
<td><span class=transitional><a href="../special/applet.html">APPLET</a>, </span><a href="blockquote.html">BLOCKQUOTE</a>, <a href="../html/body.html">BODY</a>, <a href="../forms/button.html">BUTTON</a>, <span class=transitional><a href="center.html">CENTER</a>, </span><a href="../lists/dd.html">DD</a>, <a href="../phrase/del.html">DEL</a>, <a href="div.html">DIV</a>, <a href="../forms/fieldset.html">FIELDSET</a>, <a href="../forms/form.html">FORM</a>, <span class=transitional><a href="../special/iframe.html">IFRAME</a>, </span><a href="../phrase/ins.html">INS</a>, <a href="../lists/li.html">LI</a>, <a href="../special/map.html">MAP</a>, <span class=transitional><a href="../frames/noframes.html">NOFRAMES</a>, </span><a href="noscript.html">NOSCRIPT</a>, <a href="../special/object.html">OBJECT</a>, <a href="../tables/td.html">TD</a>, <a href="../tables/th.html">TH</a></td>
</tr>
</table>
<p>The <strong class=html>PRE</strong> element contains <em>preformatted text</em>. Visual browsers should render preformatted text in a fixed-pitch font, should not collapse whitespace, and should not wrap long lines.</p>
<p><strong class=html>PRE</strong> is useful for formatting computer code or poetry where whitespace is important, but since preformatted text is inherently visual, authors should avoid dependence on it wherever possible. When using <strong class=html>PRE</strong>, authors should avoid altering the element's fixed-pitch font or non-collapsing whitespace properties by means of <a href="../../css/">style sheets</a>.</p>
<p>The following example features Java code in a <strong class=html>PRE</strong> element:</p>
<pre class=example><code class=html><PRE><CODE CLASS=Java>
class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
</CODE></PRE></code></pre>
<p>The code in the preceding example would be more difficult to read if it were not preformatted, and so <strong class=html>PRE</strong> is used to provide the proper spacing. Note that the <strong class=html><a href="../phrase/code.html">CODE</a></strong> element is also included to add structural information.</p>
<div class=transitional>
<p>The <a href="../deprecated.html">deprecated</a> <strong class=html>WIDTH</strong> attribute of <strong class=html>PRE</strong> tells the browser the expected line length of the preformatted block so that a suitable font size or margin can be used. Browsers ignore this attribute in practice.</p>
</div>
<p class=note>The <a href="../special/bdo.html#bidi">bidirectional algorithm</a> that determines the directionality of text still applies within the <strong class=html>PRE</strong> element.</p>
<h2>More Information</h2>
<ul>
<li><a href="http://www.w3.org/TR/REC-html40/struct/text.html#edef-PRE">PRE in <abbr class=initialism title="World Wide Web Consortium">W3C</abbr> HTML4.0 Recommendation</a></li>
<li><a href="http://www.w3.org/TR/REC-html32#pre">PRE in <abbr class=initialism title="World Wide Web Consortium">W3C</abbr> HTML3.2 Recommendation</a></li>
<li><a href="http://www.w3.org/MarkUp/html-spec/html-spec_5.html#SEC5.5.2">PRE in HTML2.0 Standard</a></li>
<li><a href="../../wilbur/block/pre.html">PRE in <abbr class=initialism title="Web Design Group">WDG</abbr> HTML3.2 Reference</a></li>
<li><a href="http://www.hut.fi/u/jkorpela/HTML3.2/5.44.html">PRE in <cite>Learning HTML3.2 by Examples</cite></a></li>
</ul>
<div class=footer>
<address>Maintained by <a href="http://www.htmlhelp.com/%7Eliam/">Liam Quinn</a> <<a href="mailto:liam@htmlhelp.com">liam@htmlhelp.com</a>></address>
<p class=toolbar><img src="../wdglogo-small.gif" width=105 height=40 alt="Web Design Group ~"> <a href="../index.html" rel=Start>HTML4.0Reference</a>~ <a href="../olist.html">ElementsbyFunction</a>~ <a href="../alist.html">ElementsAlphabetically</a></p>
<p class=copyright>Copyright © 1998 by <a href="http://www.htmlhelp.com/%7Eliam/">Liam Quinn</a>. This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at <a href="http://www.opencontent.org/openpub/">http://www.opencontent.org/openpub/</a>).</p>
</div>
</body>
</html>
|