Preformatted Text & Quotes

Two special text blocks: <pre>, which keeps your spacing exactly, and <blockquote> with <cite>, which marks a real quotation and its source.

HTML5 min readConcept 7 of 42

What it is

<pre> is preformatted text. Unlike a normal paragraph, it shows your content exactly as written, keeping every space, tab, and newline, and it renders in a monospace font by default. It is the natural home for code blocks and ASCII diagrams.

<blockquote> marks an extended quotation, a passage borrowed from somewhere else, and the browser usually indents it. Alongside it, the <cite> element marks the title of the work being quoted. Together they say not just how the text looks, but that it is a quote and where it came from.

Why it matters

These two elements are where the rule from the last lesson flips. Normal HTML collapses your whitespace, but <pre> is the deliberate exception, which is exactly why every code block on the web sits inside one.

Quotations matter because meaning beats appearance. Anyone can indent text with CSS, but <blockquote> and <cite> tell browsers, search engines, and assistive technology that this passage is a genuine quotation from a named source, which plain indentation never communicates.

How it works

Inside <pre>, whitespace is preserved instead of collapsed, so the text appears with the same line breaks and indentation you typed. The standard way to show code is to wrap a <code> element inside a <pre>. Because the content is still parsed as HTML, escape the syntax characters inside it: write &lt; for < and &amp; for &.

<blockquote> takes an optional cite attribute whose value is a URL pointing to the source. That attribute is machine-readable metadata only and is never shown on the page, so do not expect it to display.

To show a human-readable source, use the <cite> element, which marks the title of a creative work such as a book, article, or film and usually renders in italics. Two rules trip people up: <cite> is for the title of the work, not a person's name, and the visible attribution belongs outside the <blockquote>, in a following line or a <figcaption>, not inside the quoted text.

Try it

On the left, the same indented code inside a normal element and inside <pre>, then a real quotation. On the right, watch <pre> keep every space while the plain version collapses, and see the blockquote with its <cite> source.

<p>function hi() {
return 42;
}</p>
<pre>function hi() {
return 42;
}</pre>
<blockquote>
Used properly, words
go through anything.
</blockquote>
<p>From <cite>Brave New World</cite></p>

in a normal element:

function hi() { return 42; }

in <pre>:

function hi() {
    return 42;
}
Used properly, words go through anything.
From Brave New World

A normal element collapses the spacing; <pre> keeps it exactly.

Check yourself

Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.

  1. 1How does <pre> treat the spaces, tabs, and newlines in its content?
  2. 2What does the cite attribute on <blockquote> do?
  3. 3What is the <cite> element for?

Remember this

  • <pre> shows text exactly as written: it keeps spaces, tabs, and newlines and uses a monospace font.
  • The <pre><code> pairing is the standard way to show a code block; escape < and & inside it.
  • <blockquote> is a block-level quotation; its cite attribute is an invisible URL to the source.
  • The <cite> element marks the title of a work (not a person), and visible attribution goes outside the blockquote.

Done with this concept?

Mark it complete to track your progress. No login needed.