<pre> HTML Tag

Element of
Fonts and Web Typography
What does <pre> HTML Tag do?
The <pre> element is used to identify text that should be rendered with all line breaks and spaces intact. It is often used to preserve indenting and line breaks when displaying code blocks.
Display
inline
Usage
textual

Displaying Pre-Formatted Text

The <pre> element lets us display text exactly as it is typed, without compressing spaces or line breaks.

Code Example

We can use <pre> to display ASCII art, such as this flamingo (courtesy of ascii.co.uk):

            .-.
           ((`-)
            
             
      .="""=._))
     /  .,   .'
    /__(,_.-'
   `    /|
       /_|__
         | `))
         |
   jgs  -"==

Without the <pre> element, it would look like this:

.-.
((`-)


.="""=._))
/ ., .'
/__(,_.-'
` /|
/_|__
| `))
|
jgs -"==

Although ASCII art is great, <pre> is perhaps more useful for displaying code, scripts or tables.

Claire is seasoned technical writer, editor and HTML enthusiast.

Browser Support for pre

AllAllAllAllAllAll