The <pre> 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.
- <pre> 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 <pre> is usually shown in a monospace font.
- <pre> 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 <code>, <kbd>, <samp>, and <var> can be used with <pre>.
- CSS can be applied to customize the appearance of <pre> content.
Note: The pre tag also supports the Event Attributes in HTML and Global Attributes in HTML.
Tag | Description |
|---|
<samp> | Defines sample output from a computer program |
<var> | Defines a variable |
<code> | Defines a piece of computer code. |
<kbd> | Defines keyboard input |
Using CSS with the <pre> Tag