The HTML pre element displays preformatted text: the browser preserves spaces, indentation, and line breaks instead of collapsing them. It also uses a monospace font, making it especially handy for code and similar text. section 16.1
Use pre when the text’s layout carries useful information:
- Place code inside pre when indentation and line breaks should remain visible. section 16.1
- Remember that pre has no semantic purpose in HTML5; pair it with semantic elements such as code when appropriate. section 16.1
PLAY: Preserve a code sample
<pre><code> function helloWorld() { //Greet the reader alert('Hello World!'); } </code></pre>
