Course Content
About Lesson

Definition:


The <pre> tag in HTML is used to display preformatted text. This means that the text inside the <pre> tag will be shown exactly as it’s written in the HTML file, preserving both spaces and line breaks. This is useful for displaying code or any other text where formatting is important.

Syntax:


<pre>
Your preformatted text goes here.
    It preserves spaces and line breaks.
</pre>

Example:


HTML
<!DOCTYPE html>
<html>
<body>

    <pre>
This is a line of text.
    This is another line of text with indentations.
        And this is a third line with more indentation.
    </pre>
</body>
</html>

Output: