The pre tag is used to display preformatted text in HTML document. pre tag preserves the content structure it can be used to show pre-formated data stored in the database and in another documents and to show computer codes programs to HTML document.
Syntax:
1 | <pre>...< /pre> |
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <title> Example of HTML pre tag </title> <pre> This is a pre tag example. This preserves the text strutcture Done!! |
Result:
Pre tag can also be used to represent formatted computer codes like programing language code to show in HTML document like below
Example:
1 2 3 4 5 6 7 8 9 10 11 12 13 | <title> Example of HTML pre tag </title> <pre> function sum(){ var a=5; var b=9; var c=a+b; document.write("Sum is "+c); } |
Result: