Open In App
Related Articles

HTML <pre> Tag

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

The <pre> tag in HTML is used to define the block of preformatted text which preserves the text spaces, line breaks, tabs, and other formatting characters that are ignored by web browsers. Text in the <pre> element is displayed in a fixed-width font, but it can be changed using CSS. The <pre> tag requires a starting and end tag.

Note: The <pre> tag also supports the Event Attributes in HTML and Global Attributes in HTML.

Tag

Description

<samp>

It defines sample output from a computer program

<var>

It defines a variable

<code>

It Defines a piece of computer code.

<kbd>

It defines keyboard input

Syntax: 

<pre> Contents... </pre>

Example 1: These examples illustrate the <pre> tag in an HTML document.

HTML

<html>
    <body>
        <!-- html pre tag starts here -->
        <pre>
            GeeksforGeeks
            A Computer   Science Portal   For Geeks
        </pre>
        <!-- html pre tag ends here -->
    </body>
</html>                   

                    

Output: 

Example 2: In this article we will see the implementation of pre tag with an example.

HTML

<html>
    <head>
        <title>pre tag with CSS</title>
        <style>
            pre {
                font-family: Arial;
                color: #009900;
                margin: 25px;
            }
        </style>
    </head>
    <body>
        <!-- html pre tag starts here -->
        <pre>
            GeeksforGeeks
            A Computer   Science Portal   For Geeks
        </pre>
        <!-- html pre tag ends here -->
    </body>
</html>

                    

Output: 

Supported Browsers: 

  • Google Chrome 1
  • Edge 12
  • Firefox 1
  • Opera 15
  • Safari 4


Last Updated : 05 Jan, 2024
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads