HTML pre Tag (original) (raw)
Last Updated : 28 May, 2026
The
tag in HTML is used to display preformatted text exactly as written in the source code. It preserves spaces, line breaks, and indentation in the webpage.
tag displays text in a preformatted style.
- It preserves spaces, tabs, and line breaks.
- It is commonly used for displaying code or formatted text.
- Text inside
is usually shown in a monospace font. HTML `
This is preformatted
text.
It preserves spaces and
line breaks exactly.
`
tag preserves the exact formatting, spaces, and line breaks of text.
- It is useful for displaying code snippets, sample outputs, and formatted text.
- Tags like
, , , and can be used with.
- CSS can be applied to customize the appearance of
content.
**Note: The pre tag also supports the Event Attributes in HTML and Global Attributes in HTML.
| Tag | Description |
|---|---|
| Defines sample output from a computer program | |
| Defines a variable | |
|
Defines a piece of computer code. |
| Defines keyboard input |
Using CSS with the Tag
HTML `
This is preformatted
text.
It preserves spaces and
line breaks exactly.
`