Blockquote & Cite — HTML

<blockquote> is for a long quote, shown on a line of its own and slightly indented. <q> is for a short quote inside a sentence, and the browser adds its quote…

You're writing an article and want to include a sentence from a book you like. Readers need to know that the sentence is a quote: someone else's words, not yours. HTML has three special tags for quotes:

Long quotes with <blockquote>

Here's a sentence from the preface of a programming book:

<blockquote cite="https://example.com/sicp/preface">
  <p>Programs must be written for people to read, and only incidentally for machines to execute.</p>
</blockquote>
<cite>Structure and Interpretation of Computer Programs</cite>

The quoted sentence shows on a line of its own, slightly indented (with some space on its left and right). <blockquote> is a block element, so it always starts on a new line. Below the quote, the book title shows in italics. The address in the cite attribute doesn't show anywhere.

The cite attribute and the <cite> tag are different

The example above uses the name cite twice, for two different jobs:

So don't write the address in <cite>, and don't write the title in the cite attribute. An author's name isn't the title of a work either: write the name as plain text, outside <cite>. To keep the quote and its source together as one unit, wrap the <blockquote> and its source in a <figure> tag. Write the source in a <figcaption> tag (a caption), after </blockquote>: <figcaption>Abelson and Sussman, <cite>Structure and Interpretation of Computer Programs</cite></figcaption>.

Short quotes with <q>

Here is a short quote inside a sentence:

<p>My lecturer says <q>code is written for people to read</q>, so keep your code as tidy as you can.</p>

<q> is an inline element, so the quote stays inside the sentence and doesn't move to a new line. The browser adds the quote marks at the start and end of the quote.

The page shows one whole sentence, with "code is written for people to read" already inside quote marks. Because the browser adds them, don't type " inside <q> as well.

⚠️ Which is the quote, which is the title?

TL;DR: <blockquote> is for a long quote, shown on a line of its own and slightly indented. <q> is for a short quote inside a sentence, and the browser adds its quote marks. The web address of the quote's source goes in the cite="..." attribute, in the opening tag of <blockquote> or <q>, and doesn't show. The title of the work you quote from (such as a book) goes in a <cite> tag, and shows in italics.

⚡ A long quote

Write:

<blockquote cite="https://example.com/sicp/preface">
  <p>Programs must be written for people to read, and only incidentally for machines to execute.</p>
</blockquote>
<cite>Structure and Interpretation of Computer Programs</cite>

Meaning: <blockquote> marks a long quote. It is a block: the quote shows on a line of its own, slightly indented. The <cite> after it holds the title of the book you quote from, shown in italics.

⚡ Two different cites

Guess first: where does the address in cite="..." show?

Nowhere. The address stays in the code, so other programs like search engines can read it.

Meaning: The cite="..." attribute holds the web address of the quote's source. The <cite> tag holds the title of a work, such as a book. An author's name isn't a title, so it goes outside <cite>.

⚡ A short quote inside a sentence

Write:

<p>My lecturer says <q>code is written for people to read</q>, so keep your code as tidy as you can.</p>
Guess first: do you type the quote marks?

No. The browser adds them. If you type them too, the quote marks show twice.

Meaning: <q> is inline, so the short quote stays inside the sentence. <blockquote> is for a long quote that shows on a line of its own.

What you will learn