HTML <pre> Tag


The <pre> HTML tag, short for "preformatted text," is used to display text exactly as it appears in the HTML code, preserving spaces, line breaks, and formatting. It is typically used for displaying code snippets, poetry, ASCII art, or any content where the formatting and whitespace are essential. When text is enclosed within the <pre> tag, browsers will render it using a monospaced font, such as Courier, which ensures that each character takes up the same amount of space. This tag is valuable for maintaining the integrity of text formatting, making it easier to showcase code examples or any content where maintaining spacing and line breaks is crucial.


Permitted Parents
Any element that accepts flow content
Most inline tags and text
Start/End Tags
Start tag: required, End tag: required


Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks



Global Attributes

The <pre> tag also supports the Global Attributes in HTML5

Event Attributes

The <pre> tag also supports the Event Attributes in HTML5

Browser Support

The following table will show you the current browser support for the HTML <pre> tag.

Edge Chrome Firefox Opera Safari
Tablets / Mobile
Chrome Firefox Opera Safari Samsung Webview

Last updated by CSSPortal on: 30th March 2024