Open In App
Related Articles

HTML <pre> Tag

Improve Article
Improve
Save Article
Save
Like Article
Like

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 which 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.
Syntax: 
 

<pre> Contents... </pre>

Below examples illustrate the <pre> tag in HTML:
Example 1: 
 

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: 
 

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
  • Edge 12
  • Internet Explorer
  • Firefox 1
  • Opera
  • Safari

 


Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 28 Jul, 2022
Like Article
Save Article
Similar Reads
Related Tutorials