It is used to display text as it has been written in the HTML, keeping spaces and line breaks.
The browser will display the text using the default monospaced font, unless it is overwritten with CSS.
When using preformatted text to represent an image or diagram, it is important to provide an alternate description for people who use assistive technology to navigate, such as a screen reader. To do this, a combination of
<figcaption> will be used, plus a combination of an
id and the
aria-labelledby attributes as follows:
- Type: block
- Self-closing: No
- Semantic value: No