ad

Wednesday, September 17, 2025

How to Use the <pre> Tag in HTML (With Examples)


 


4] Pre Tag  

The <pre> tag defines preformatted text.Text in a <pre> element is displayedto the fixed-width font usually Courier and it iHow to Create Paragraphs in HTMLs preserves both spaces and line breaks. Use the <pre> element when displaying text with unusual formatting, or some sort of computer code.

·        ·  <pre> stands for preformatted  is used to display text exactly as it is written in the HTML code.

·  It preserves both spaces and line breaks 

<!DOCTYPE html>

<html>
 <body>
 <pre>
 Text in a pre element 
is displayed in a fixed-width
 font, and it preserves
 both spaces and
 line breaks
 </pre> 
 </body>

 </html>

Explain Program

Step 1 ]

<!DOCTYPE html>

  •  document type declaration.
  • browser help this is an HTML5 document.

Step 2 ]  

. <html> ... </html>

  • root element of the HTML document.
  • <html> tag is part of the web page.

Step 3 ]  

<body> ... </body>

  • HTML document that holds visible content on the page.
  • anything  contains type inside <body> will be display the browser

Step 4]  

 <pre> ....</pre>

  •    <pre> tag  is Preformatted text tag 
  • <pre> tag  inside  use space and line breaks .


OUTPUT IN PRE TAG 


Text in a pre element 
is displayed in a fixed-width
 font, and it preserves
 both spaces and
 line breaks

f

Related Post :- 


How to Set Image Height in HTML Using the <img> Tag


No comments:

Post a Comment