<pre> - HTML CSS HTML Tag

HTML CSS examples for HTML Tag:pre

Introduction

pre marks Preformatted Content, such as computer code.

The pre element preserves the whitespace from collapsing.

The pre Element summary

Item Value
Elementpre
Local Attributes None
Tag Style Start and end tag required
New in HTML5 No
Changes in HTML5 None

Style Convention

pre {
   display: block;
   font-family: monospace;
   white-space: pre;
   margin: 1em 0;
}

Using the pre Element

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
   <head> 
      <title>Example</title> 
   </head> 
   <body> 
      <pre>
         <code>
          var items = ["CSS", "HTML", "mangoes", "Oracle"];
          for (var i = 0; i &lt; items.length; i++) {
              document.writeln("I like " + items[i]);
          }<!--from ww w. j av  a  2s  . c  o m-->
              </code>
      </pre>  
   </body>
</html>

Related Tutorials