html tutorial - <pre> Preformatted Text Tag in HTML - html5 - html code - html form



  • The <pre> tag is representing preformatted text.
  • The text within this element is displayed in monospace font.
  • The <pre> tag is displayed with fixed-width font and it reserves both line break and spaces.
  • <pre> tag is belongs to Palpable content and Flow content.

Syntax for <pre> tag in HTML:

<pre>content</pre>

Differences between HTML 4.01 and HTML 5 for <pre> tag:

HTML 4.0.1

  • HTML 4 is supports all the attributes of <pre> tag.

HTML 5

  • HTML 5 is not supports width attribute of <pre> tag.

Sample Coding for <pre> tag in HTML:

Tryit<!DOCTYPE html>
<html >
    <head>
        <title>Wikitechy pre tag</title>
    </head>
    <body>
        <h3>Wikitechy HTML pre tag.</h3>
        <pre>
        The HTML  pre element represents preformatted text. 
        Whitespace inside this element is displayed as typed.
        </pre>
        <p>
        The HTML  pre element represents preformatted text. 
        Whitespace inside this element is displayed as typed.
        </p> 
    </body>
</html>

Code Explanation for <pre> tag in HTML:

Preformatted Text <pre> Tag Code Explanation

  1. The text within the <pre> element will be displayed as a preformatted text.

Output for <pre> tag in HTML:

Preformatted Text <pre> Tag Output

  1. <pre> tagged text is displayed the preformatted form with line break and spaces.
  2. But the normal text remove unwanted spaces.

Attribute for <pre> tag:

Attribute Value HTML 4 HTML 5 Description
width number Yes No It is used to set the maximum number of a characters per line.

Browser Support for <pre> tag in HTML:

Yes Yes Yes Yes Yes

Tips and Notes

  • By using the <pre> element the text is displayed with unusual format or some sort of computer code.
  • It displayed line between the paragraphs.

Related Searches to <pre> tag in html