HTML blockquote: How to Quote Text (and Style It with CSS)

By Marko Denic
Contents
  1. Basic blockquote
  2. Add attribution with figure and figcaption
  3. Short quotes inside a sentence: q
  4. Styling a blockquote
  5. The quotation mark trick
  6. Customize the q element's quotation marks
  7. When to use blockquote
  8. FAQ

The <blockquote> element marks a longer quotation from another source, set apart from the surrounding text. Browsers indent it by default; the rest of the styling is up to you.

Basic blockquote

Put the quoted text inside, usually wrapped in <p> tags. The optional cite attribute holds the URL of the source. Browsers don’t display it, but it’s useful metadata.

html
<blockquote cite="https://www.w3.org/standards/webdesign/accessibility">
  <p>The power of the Web is in its universality. Access by everyone
  regardless of disability is an essential aspect.</p>
</blockquote>

Add attribution with figure and figcaption

Who said it doesn’t belong inside the <blockquote>, because it isn’t part of the quote. Wrap both in a <figure> and put the attribution in a <figcaption>. Use <cite> for the title of a work (a book, article or talk), not for a person’s name. Browsers show <cite> in italics by default.

html
<figure>
  <blockquote>
    <p>The power of the Web is in its universality.</p>
  </blockquote>
  <figcaption>
    Tim Berners-Lee, <cite>W3C Web Accessibility Initiative</cite>
  </figcaption>
</figure>

Short quotes inside a sentence: q

For a quote within a paragraph, use the inline <q> element. Browsers add quotation marks automatically, in the right style for the page’s language.

html
<p>As the saying goes, <q>premature optimization is the root of all evil</q>.</p>

Styling a blockquote

Three common styles. Reset the browser’s default margins first, then add your own.

Demo:

Simplicity is prerequisite for reliability.

Edsger W. Dijkstra

Programs must be written for people to read, and only incidentally for machines to execute.

Harold Abelson

Make it work, make it right, make it fast.

Kent Beck

The quotation mark trick

The big quote mark in the second example is a ::before pseudo-element with the Unicode left double quotation mark (\201C), so it never appears in the HTML or gets copied with the text.

css
blockquote {
  position: relative;
  padding-left: 40px;
}

blockquote::before {
  content: "\201C";
  position: absolute;
  left: 0;
  top: -10px;
  font: 700 56px/1 Georgia, serif;
  color: #3b82f6;
}

Customize the q element's quotation marks

The quotes property controls which characters <q> uses, including for nested quotes.

css
q {
  quotes: "\201C" "\201D" "\2018" "\2019"; /* “ ” then ‘ ’ when nested */
}

When to use blockquote

  • Do use it for text quoted from another source: a person, a book, documentation, another article.
  • Don’t use it just to indent text or to make a callout box. Style a <div> or <aside> for that.
  • Pull quotes (a line from your own article, repeated in large type) aren’t really quotations. Use <aside> and hide the duplicate from screen readers with aria-hidden="true".
  • Testimonials are quotes, so <figure> + <blockquote> + <figcaption> is a good fit.

Getting these semantics right is the kind of thing these HTML tips are about: browsers, screen readers and search engines all understand the page better. For notes that readers shouldn’t see at all, use HTML comments.

FAQ

What is the difference between blockquote and q?

<blockquote> is for block-level quotes that stand on their own. <q> is for short quotes inside a sentence, and browsers add the quotation marks for you.

Does the cite attribute show on the page?

No. It’s machine-readable only. Show the source visibly with a <figcaption> or a link.

How do I remove the indent from a blockquote?

The indent is the browser’s default margin. Set blockquote { margin: 0; } and add your own padding.

Can I put a blockquote inside a paragraph?

No. A <blockquote> is a block element and can’t go inside <p>. Use <q> for quotes within a sentence.