{{HTMLRef}}
The HTML Preformatted Text (<pre>) represents preformatted text. Text within this element is typically displayed in a non-proportional font exactly as it is laid out in the file. Whitespaces inside this element are displayed as typed.
Content categories | Flow content, palpable content. |
---|---|
Permitted content | Phrasing content. |
Tag omission | {{no_tag_omission}} |
Permitted parent elements | Any element that accepts flow content. |
DOM interface | {{domxref("HTMLPreElement")}} |
Attributes
This element only includes the global attributes.
- {{htmlattrdef("cols")}} {{non-standard_inline}}{{obsolete_inline}}
- Contains the preferred count of characters that a line should have. It was a non-standard synonym of {{htmlattrxref("width", "pre")}}. To achieve such an effect, use CSS styling instead.
- {{htmlattrdef("width")}} {{obsolete_inline}}
- Contains the preferred count of characters that a line should have. Though technically still implemented, this attribute has no visual effect; to achieve such an effect, use CSS styling instead.
- {{htmlattrdef("wrap")}} {{non-standard_inline}}
- Is a hint indicating how the overflow must happen. In modern browser this hint is ignored and no visual effect results in its present; to achieve such an effect, use CSS styling instead.
Examples
<!-- Some example CSS code --> <pre> body { color:red; } </pre>
Result
body { color:red; }
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('HTML WHATWG', 'grouping-content.html#the-pre-element', '<pre>')}} | {{Spec2('HTML WHATWG')}} | No significant change from {{SpecName("HTML WHATWG")}} |
{{SpecName('HTML5 W3C', 'grouping-content.html#the-pre-element', '<pre>')}} | {{Spec2('HTML5 W3C')}} | No significant change from {{SpecName("HTML4.01")}} |
{{SpecName('HTML4.01', 'struct/text.html#h-9.3.4', '<dl>')}} | {{Spec2('HTML4.01')}} | Deprecated the cols attribute |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1.0 | {{CompatGeckoDesktop("1.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
width |
{{CompatVersionUnknown}}[1] | {{CompatGeckoDesktop("1.0")}} {{CompatGeckoDesktop("29.0")}}[1] |
{{CompatVersionUnknown}}[1] | {{CompatVersionUnknown}}[1] | {{CompatVersionUnknown}}[1] |
cols |
{{CompatNo}} | {{CompatGeckoDesktop("1.0")}} {{CompatNo}} {{CompatGeckoDesktop("29.0")}} |
{{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
wrap |
{{CompatUnknown}} | {{CompatGeckoDesktop("1.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatGeckoMobile("1.0")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
width |
{{CompatUnknown}} | {{CompatGeckoMobile("1.0")}}{{CompatGeckoMobile("29.0")}}[1] | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
cols |
{{CompatNo}} | {{CompatGeckoMobile("1.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
wrap |
{{CompatUnknown}} | {{CompatGeckoMobile("1.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[1] Specifying the width
attribute has no layout effect.
See also
- CSS: {{Cssxref('white-space')}}, {{Cssxref('word-break')}}