Skip to content
Related Articles

Related Articles

HTML | <pre> Tag
  • Difficulty Level : Basic
  • Last Updated : 21 Jul, 2020

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>
    <head>
        <title>pre tag</title>
    </head>
    <body>
        <pre>
            GeeksforGeeks
            A Computer   Science Portal   For Geeks
        </pre>
    </body>
</html>                    

Output:



Example 2:




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

Output:

Supported Browsers: The browser supported by <pre> tag are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari
My Personal Notes arrow_drop_up
Recommended Articles
Page :