Occasionally it is desirable to output content as it is laid out in the code, whitespace and all. The
<pre> tag is used for this purpose. It is often used in online coding tutorials so that the whitespace shown in the tutorial reflects how it would appear in the document it represents. The code below shows how
<pre> is used.
<!DOCTYPE HTML> <html lang="en"> <head> <meta charset="UTF-8"> <title>Preformatted Text</title> </head> <body> <h1>Your First HTML Page</h1> <pre> <!DOCTYPE html> <html lang="en"> <head> <title>Hello world!</title> </head> <body> <h1>Hello world!</h1> </body> </html> </pre> </body> </html>
The page is rendered as follows: