DEV Community

Cover image for HTML tags | pre
Carlos Espada
Carlos Espada

Posted on • Edited on

HTML tags | pre

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 and example | Support

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay