skip to content

In HTML, when do you use <q> versus <blockquote>, and what do the cite attribute and the <cite> element each do?

level: middleimportance: should knowfreq 30%

answer

  1. one is inline, one is a block
  2. the browser supplies one pair of marks
  3. attribute holds a URL nobody sees
  4. element names a work, not a person
  5. attribution lives outside the block

basics

~20 s

Use q for a short quotation inside a sentence and blockquote for one that stands as its own block. The cite attribute holds a source URL that browsers never display, while the cite element marks the title of a work.

solid answer

~40 s

`<q>` is for a short quotation running inside a sentence; `<blockquote>` is for a quotation that stands on its own as a block. Browsers' default stylesheet inserts the quotation marks around `<q>`, so typing your own gives the reader two sets. Both elements accept a `cite` attribute whose value is a URL identifying the source — but browsers render nothing for it and it is not surfaced to assistive technology, so if readers should be able to reach the source you still need a visible link. The `<cite>` element is a different thing entirely: it marks the **title of a work** — a book, film, article or specification — rather than the name of the person being quoted. And the spec is explicit that attribution belongs outside the `<blockquote>`, not inside it.

code

html · 6 lines
html
<p>She called it <q>the last honest interface</q> and moved on.</p>

<blockquote cite="https://example.com/essay">
  <p>The best interface is the one you never notice.</p>
</blockquote>
<p>&mdash; Dana Reyes, <cite><a href="https://example.com/essay">Quiet Software</a></cite></p>

go deeper

for a junior

Know that q is for a short quotation inside a sentence and blockquote for a standalone one, and that you do not type your own quotation marks around q.

for a middle

Explain the three easily confused pieces: the browser-generated marks on q, the cite attribute as an unrendered source URL, and the cite element as the title of a work.

for a senior

Show judgment about provenance — a machine-readable cite attribute plus a visible link, attribution outside the blockquote, and semantics never used as a substitute for indentation.

for a principal

Own the editorial conventions: one house pattern for quotations and credits across templates and CMS output, so provenance is consistent, extractable and legally defensible rather than per-author improvisation.

## Inline versus block The first decision is structural. `<q>` is phrasing content: it lives inside a sentence, the way a quoted fragment does in prose. `<blockquote>` is flow content: it is its own block, for a quotation long enough to stand apart. ```html <p>She called it <q>the last honest interface</q> and moved on.</p> <blockquote> <p>The best interface is the one you never notice.</p> </blockquote> ``` The rule of thumb interviewers want: if the quotation interrupts a sentence, `<q>`; if it stands between paragraphs, `<blockquote>`. ## The quotation marks come from the browser `<q>` is unusual: the browser's default stylesheet generates the opening and closing quotation marks for you, and which marks it uses follows the language in effect, so the same markup produces English, French or German conventions when `lang` is set correctly. The practical consequence is simple — **do not type quotation marks inside `<q>`**, or you get two sets: ```html <p>He said <q>"hello"</q>.</p> <!-- renders with doubled marks --> <p>He said <q>hello</q>.</p> <!-- correct --> ``` Nested `<q>` elements produce the inner quotation convention (single marks in English), which is the other reason to let the browser handle it. `<blockquote>`, by contrast, gets no generated marks — the default rendering indents it and nothing more. ## The `cite` attribute Both `<q>` and `<blockquote>` accept `cite`, and it is one of the most misunderstood attributes in HTML. Its value is a **URL** identifying the source document: ```html <blockquote cite="https://example.com/interview"> <p>We shipped it in a weekend.</p> </blockquote> ``` What it does for users: nothing. No browser renders it, it is not a link, it does not appear in a tooltip, and it is not exposed to assistive technology. It is a machine-readable annotation that a script or a tool could read. So if you want the reader to be able to reach the source — and usually you do — you must also provide a visible, real link. Treating `cite` as "the way you credit a quote" is the classic wrong answer. ## The `<cite>` element Different element, different job: `<cite>` marks the **title of a work** — a book, a paper, a film, a song, a specification, a blog post. The spec is specific that it is for the title of the work, not for the name of a person. That trips up a lot of candidates, because the traditional print convention is to italicise both, and `<cite>` happens to render italic by default. ```html <p>The pattern is described in <cite>The Design of Everyday Things</cite>.</p> ``` So the person's name is plain text (or a link to their page); the work's title is `<cite>`. ## Where attribution goes The specification states that attribution for a quotation, if any, must be placed **outside** the `<blockquote>` element. The blockquote's contents are the quotation itself, and nothing else. In practice you put the attribution in a following paragraph, or wrap quotation and attribution together in a containing element that carries the credit: ```html <blockquote cite="https://example.com/essay"> <p>The best interface is the one you never notice.</p> </blockquote> <p>— Dana Reyes, <cite><a href="https://example.com/essay">Quiet Software</a></cite></p> ``` The em dash and name are text, the work's title is `<cite>`, the reachable source is a real link, and the machine-readable source URL sits in `cite="…"`. ## Pitfalls to name in an interview Typing quotation marks inside `<q>`. Using `<blockquote>` to indent something that is not a quotation — indentation is a styling decision and does not belong to a semantic element. Putting the attribution inside the `<blockquote>`, which makes the credit part of the quoted words. Using `<cite>` for the speaker's name. And believing the `cite` attribute credits or links the source; it records a URL, and only a visible link actually delivers it.

  • If the cite attribute is never rendered, why would you set it at all?
    Because it records the source in the document for anything that parses the markup — a content pipeline, a scraper, an editor tool, your own script. It costs one attribute and makes the provenance explicit in the source. What it must never be is your only credit: a reader can neither see nor follow it, so a visible link stays mandatory whenever the source matters to people.
  • Why should you avoid typing quotation marks inside <q>?
    The browser's default stylesheet already generates them, and which glyphs it uses follows the language in effect, so typed marks give the reader a doubled pair and defeat the language-aware behaviour. Nested `<q>` elements also switch to the inner convention automatically. Let the element supply the punctuation and keep the quoted words alone in the content.
  • Where does the attribution for a blockquote belong, and why?
    Outside the `<blockquote>`, per the spec. Everything inside the element is the quotation, so a name placed inside becomes part of the quoted words — misleading to anyone extracting the quote and to a reader relying on the semantics. Put the credit in a following paragraph, or group the quote and its credit in a containing element that carries the attribution.

saying these in an interview costs you the question

  • Thinks the cite attribute renders or links the source
  • Types quotation marks inside a q element
  • Uses <cite> for the name of the person quoted
  • Uses blockquote to indent non-quoted content
  • Puts the attribution inside the blockquote

context