Pre Tag – How to Use PRE Tag in HTML with Example

Pre tag in HTML

You may have notice when we insert an extra space in our HTML code then output in the browser does not effect. Sometimes using <br> tag to insert a new line again and again become headache. See in the example we have inserted 2 extra lines and many extra spaces but output is on same line.

Example Code

extra space in html

Example Output

No extra space in browser

There is a solution for both of this problems and that is <pre> tag. You can write the whole code inside <pre> tag to insert line breaks and extra spaces.  <pre> tag display everything as it is written in HTML code.

Syntax of <pre> tag.

<pre>   Text Here   </pre>

Example of <pre> tag in HTML

Example Code

Pre tag in HTML

Example Output

Pre tag example in HTML





Please enter your comment!
Please enter your name here