How to add preformatted text in HTML?

HTMLFront End TechnologyWeb Development

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>
raja
Published on 13-Mar-2018 08:26:49
Advertisements