HTML pre Tag :
- To display text in Pre formatted format.
- Text in a <pre> element is displayed with pre-defined format.
- It is in a fixed-width and font (usually Courier), and it preserves both spaces and line breaks.
<!DOCTYPE html>
<html>
<body>
<pre>
Text displaying with pre
tag will be displayed on
web page with a fixed width,
font, spaces and line breaks.
</pre>
</body>
</html>
Default CSS Settings for <pre> tag : Most browsers will display the <pre> element with the following default values.
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0;
The following example explains how CSS code pre-defined for paragraph text:
<!DOCTYPE html>
<html>
<head>
<style>
pre {
display: block;
font-family: monospace;
white-space: pre;
margin: 1em 0;
}
</style>
</head>
<body>
<p>A pre element is displayed like this:</p>
<pre>
Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks
</pre>
<p>Change the default CSS settings to see the effect.</p>
</body>
</html>