Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<pre>

Text that keeps all spaces and line breaks.

Syntax

<pre>preformatted text</pre>

Examples

A code block with indentation:

<pre><code>function greet(name) {
  return "Hello, " + name;
}</code></pre>

Text art:

<pre>
  /\_/\
 ( o.o )
  &gt; ^ &lt;
</pre>

Notes

Long lines inside <pre> do not wrap and may stick out of the box; add overflow: auto or white-space: pre-wrap. A line break right after the opening tag is ignored by the browser.

See also

  • <code> — A piece of code inside text; shown in a monospace font.
  • <br> — A line break inside text; `<wbr>` marks where a line may break if space runs out.

In the tutorial

  • Text formatting — Inline tags for text — strong and em, mark, del and ins, sub and sup, code, kbd and pre, abbr and q.

Thanks for reading!

Donate to the site — we work hard for you.