HTML Preformatted Text

The < pre > element contains preformatted text, that is all the spaces and carriage returns are shown exactly as you type them in the source file.

<pre> Sample <html> Tag </pre>

When you run above html code the output you will get like this

Sample <html> Tag

Text in a < pre > element is displayed in a fixed-width font, should not collapse whitespace, and should not wrap long lines. You can use preformatted text for displaying text with unusual formatting, or some sort of computer code.

<pre> for(int i=0;i<=10;i++) { //loop statements here } </pre>

When you run this HTML code , it will look like same as in HTML source file

for(inti=0;i<=10;i++) { //loop statements here }

The < pre > tag is supported in all major browsers, but this can sometimes cause the browser to extend the page beyond the edges of the browser window when the lines are too long.

A sample usage of < pre > element.

html-pre

HTML Source Code :

<html> <body> <pre> Product Name Qty Price Total ============ ==== ====== ===== Product1 12 100 1200 Product2 10 200 2000 Product3 15 150 2250 ========================================== Total 5450 ========================================== </pre> </body> </html>