DEV Community

Cover image for HTML tags | pre

HTML tags | pre

Carlos Espada
Frontend developer. Cyclist. Fan of trains, dinos and XIX century travels. Trying to do my part for making an accessible, light and fast internet for everyone.
・1 min read

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 <figure> and <figcaption> will be used, plus a combination of an id and the role and aria-labelledby attributes as follows:

< I'm an expert in my field. >
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
A cow saying, "I'm an expert in my field." The cow is illustrated using preformatted text characters.
  • Type: block
  • Self-closing: No
  • Semantic value: No

Definition | Example | Support

Discussion (0)