HTML <pre> tag
- Previous Page <picture>
- Next Page <progress>
Definition and usage
<pre>
Tag defines preformatted text.
<pre>
Text within the element is displayed in a monospaced font, preserving spaces and newline characters. The text will be displayed exactly as it is written in the HTML source code.
See also:
Tag | Description |
---|---|
<code> | Define example output of a computer program. |
<samp> | Define keyboard input. |
<kbd> | Define keyboard input. |
<var> | Define variables. |
See also:
HTML Tutorial:HTML Text Formatting
HTML DOM Reference Manual:Pre object
Instance
Example 1
Preformatted text:
<pre> Text within the pre element Displayed in a monospaced font, And retain at the same time Spaces and Line breaks. </pre>
Example 2
How to create a preformatted text with fixed width (using CSS):
<div style="width:200px;overflow:auto"> <pre>This is a pre with fixed width. It will use the specified space.</pre> </div>
Global Attributes
<pre>
The tag also supports Global Attributes in HTML.
event attributes
<pre>
The tag also supports Event Attributes in HTML.
Default CSS Settings
Most browsers will display the following default values <pre>
Element:
pre { display: block; font-family: monospace; white-space: pre; margin: 1em 0; }
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
- Previous Page <picture>
- Next Page <progress>