HTML pre Tag defines preformatted text, The text inside pre tag is displayed as it is. Line breaks and Spaces are also displayed and the formation of text is kept as it is while displaying it.
Table of Contents
Syntax of HTML pre Tag
The Syntax of HTML pre Tag is shown below, It has both starting tag and ending tag.
<pre>
</pre>
Usage of HTML pre Tag
HTML pre Tag is used to display the text as it is written in HTML code. User can control the text formation directly from the HTML code.
The pre tag is mostly used for poetry and quotes.
Example of HTML pre Tag
Simple example of HTML pre Tag is given below.
<pre>
This is first line of Pre Tag.
This is second line of Pre Tag after a line break.
</pre>
Output
This is first line of Pre Tag. This is second line of Pre Tag after a line break.
In above example we have used pre tag to display the text as it is. Line break used in HTML code is preserved by the pre tag.
Browser Support for HTML pre Tag
HTML pre Tag is supported by all major browsers which include Chrome, Opera, Firefox, Edge and Safari.
Global Attributes Support in HTML pre Tag
The HTML pre Tag supports all Global Attributes.
Event Attributes Support in HTML pre Tag
The HTML pre Tag supports all Event Attributes.