Summary -

In this topic, we described about the <pre> tag along with detailed example.

Preformatted text in HTML document. HTML paragraphs are defined by using <pre> tag. But the paragraph will display as how it is formatted in HTML document.

For these cases, the paragraph content will go in between opening <pre> tag and closing </pre> tag. Browsers normally extract <pre> text in a fixed-pitched font with whitespace together and without word wrap.

The tag can be specified like <pre></pre> with the text inserted in between the opening and closing tags.

Syntax -

<pre>..text here.. </pre>

Optional Attributes -

AttributeDescriptionValues
WidthSpecifies the max number of char per line.Not supported in HTML5number

Example -

<!DOCTYPE html>
<html>
	<head>
		<title>Preserve formatting tag example..</title>
	</head>
	<body>
		<pre>First paragraph text here…
		Second paragraph text here…
		Third paragraph text here…</pre>
	</body>
</html>

Output -

First paragraph text here…
Second paragraph text here…
Third paragraph text here…