The <pre>
represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically rendered using a non-proportional ("monospace") font. Whitespace inside this element is displayed as written.
Content categories | Flow content, palpable content. |
---|---|
Permitted content | Phrasing content. |
Tag omission | None, both the starting and ending tag are mandatory. |
Permitted parents | Any element that accepts flow content. |
Permitted ARIA roles | Any |
DOM interface | HTMLPreElement |
This element only includes the global attributes.
cols
width
. To achieve such an effect, use CSS width
instead.width
width
instead.wrap
white-space
instead.<!-- Some example CSS code --> <pre> body { color:red; } </pre>
body { color:red; }
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<pre>' in that specification. | Living Standard | No significant change from HTML5 |
HTML5 The definition of '<pre>' in that specification. | Recommendation | No significant change from HTML 4.01 Specification |
HTML 4.01 Specification The definition of '<pre>' in that specification. | Recommendation | Deprecated the cols attribute |
Feature | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | Yes | Yes | 1 | Yes | Yes | Yes |
cols |
No | No | 1 — 29 | No | No | No |
width |
Yes1 | Yes1 | 12 | Yes1 | Yes1 | Yes1 |
wrap |
? | No | 1 | ? | ? | ? |
Feature | Android webview | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
---|---|---|---|---|---|---|---|
Basic support | Yes | Yes | Yes | 4 | Yes | Yes | Yes |
cols |
No | No | No | 4 — 29 | No | No | No |
width |
Yes1 | Yes1 | Yes1 | 42 | Yes1 | Yes1 | Yes1 |
wrap |
? | ? | No | 4 | ? | ? | ? |
1. Specifying the width
attribute has no layout effect.
2. Since Firefox 29, specifying the width
attribute has no layout effect.
white-space
, word-break
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre