Computer >> Computer tutorials >  >> Programming >> HTML

How to add preformatted text in HTML?


Use the <pre> tag to add preformatted text in HTML. The HTML <pre> tag is used for indicating preformatted text. The code tag surrounds the code being marked up.

Browsers normally render pretext in a fixed-pitched font, with whitespace intact, and without word wrap.

Example

You can try to run the following code to learn how to work with <pre> tag −

<!DOCTYPE html>
<html>
   <head>
      <title>HTML pre Tag</title>
   </head>
   <body>
      <pre>
         This text is
         in a fixed-pitch
         font, and it preserves
         both spaces and line breaks
      </pre>
   </body>
</html>