HTML Quotations
Whenever you quote someone else’s words on a web page, you should mark that text up as a quotation rather than just wrapping it in a plain paragraph. HTML gives you dedicated elements for this: <blockquote> for longer, block-level quotations, <q> for short quotations inside a sentence, and <cite> for naming the title of the work being referenced. Using these correctly improves accessibility, gives search engines and browsers real semantic meaning, and lets you skip manually typing quotation marks.
Overview: How Quotations Work in HTML
HTML separates the idea of “this text is a quotation” from “this text should look indented” or “this text should have quote marks around it.” The elements only carry meaning; the visual presentation comes from the browser’s default stylesheet (which you can override with CSS).
<blockquote> is a block-level element, meaning it starts on its own line and takes up the full width available to it, just like a <p> or a <div>. Most browsers apply a default left and right margin to it (commonly around 40px) purely through the built-in user-agent stylesheet — this is presentation, not semantics, and you should not rely on it for consistent spacing across browsers. If you want reliable, predictable indentation or styling, control it with CSS in a real stylesheet rather than depending on the default.
<q>, by contrast, is an inline element. It sits in the flow of a sentence the same way <strong> or <em> does. Browsers automatically insert quotation marks around its content using generated CSS content (::before and ::after pseudo-elements with content: open-quote and content: close-quote). This means you should never type your own quotation marks inside a <q> element — the browser adds them for you.
Both <blockquote> and <q> accept an optional cite attribute. This attribute holds a URL pointing to the source of the quotation. Crucially, the cite attribute is never displayed to the reader — it’s metadata for browsers, search engines, and accessibility tools. If you want the source to be visible on the page (for example, “— Steve Jobs”), you write that separately, typically using the <cite> element or a <footer> inside the blockquote.
The <cite> element is different from the cite attribute. It’s an inline element used to mark up the title of a creative work — a book, article, film, song, or similar — and browsers typically render its content in italics by default. Strictly, the HTML specification defines <cite> as naming the work itself, not the author, though in practice many sites also wrap author names in it; being aware of the distinction helps you make an informed choice.
Syntax
<blockquote cite="URL">
<p>Longer quoted text goes here.</p>
</blockquote>
<p>Short quote: <q cite="URL">quoted text</q></p>
<cite>Title of the work</cite>
| Element / Attribute | Type | Purpose |
|---|---|---|
<blockquote> |
Block-level | Marks an extended quotation set apart from the surrounding content |
<q> |
Inline | Marks a short quotation embedded within a sentence; browser adds quote marks automatically |
<cite> |
Inline | Names the title of a referenced work (book, article, etc.) |
cite attribute |
Attribute on <blockquote>/<q> |
A URL identifying the source; not displayed to the user |
Examples
Example 1: A basic block quotation
<blockquote>
<p>The only way to do great work is to love what you do.</p>
</blockquote>
Result: The sentence appears as its own indented block, set apart from the paragraphs around it, using the browser’s default block-quote margin.
This is the simplest valid use of <blockquote>: a single paragraph wrapped inside it. Even a one-sentence quote should still use a <p> inside the blockquote so the markup stays valid and extensible if more paragraphs are added later.
Example 2: A blockquote with a source and attribution
<blockquote cite="https://www.w3.org/TR/html52/">
<p>The <code>cite</code> attribute, if present, must be a valid URL potentially surrounded by spaces.</p>
<footer>— <cite>HTML 5.2 Specification, W3C</cite></footer>
</blockquote>
Result: An indented block quotation appears, followed on its own line by “— HTML 5.2 Specification, W3C”, with the title rendered in italics by the browser’s default styling of <cite>.
Here the invisible cite attribute records the exact source URL, while the visible <footer> and <cite> combination gives human readers a readable attribution line. This is the recommended pattern when you need both machine-readable and human-readable sourcing.
Example 3: An inline quotation within a sentence
<p>As the old saying goes, <q>practice makes perfect</q>, and it applies to coding just as much as anything else.</p>
Result: The sentence reads inline as: As the old saying goes, “practice makes perfect”, and it applies to coding just as much as anything else — with quotation marks inserted automatically by the browser around the quoted phrase.
Notice that no literal quotation mark characters were typed in the source markup. The browser’s default stylesheet generates them, which also means the correct quote style for the page’s language is used automatically in browsers that implement locale-aware quoting.
How the Browser Parses and Renders Quotations
When the HTML parser encounters a <blockquote> or <q> start tag, it creates a DOM node using the HTMLQuoteElement interface for both elements — they share the same underlying interface, differing only in their default CSS display type. Any cite attribute is stored as a property on that node (accessible in JavaScript as element.cite), even though it plays no visual role.
For <blockquote>, the browser’s default stylesheet applies display: block along with default top/bottom/left/right margins, so the rendering engine lays it out as its own block box in the document flow, with any child elements (typically paragraphs) rendered inside that box.
For <q>, the default stylesheet applies display: inline plus generated content rules roughly equivalent to q::before { content: open-quote; } and q::after { content: close-quote; }. These pseudo-elements are inserted into the render tree — not the DOM — so they’re purely visual and won’t appear if you inspect the element’s text content in JavaScript. The specific quote glyphs used depend on the quotes CSS property and the document or element’s language, set via the lang attribute.
Common Mistakes
Mistake 1: Using q for long, multi-sentence quotations
<q>This is a long quotation that runs across several sentences and really should stand apart from the surrounding paragraph instead of being squeezed inline with quotation marks wrapped awkwardly around all of it.</q>
This is technically valid markup, but it’s a semantic misuse. <q> is meant for short, inline quotations; stuffing a lengthy passage into it produces an oddly long inline run of quoted text instead of a properly separated block. Long quotations belong in <blockquote>.
<blockquote>
<p>This is a long quotation that runs across several sentences and really should stand apart from the surrounding paragraph.</p>
</blockquote>
Mistake 2: Manually typing quotation marks inside q
<p>She said, <q>"I'll be there by noon."</q></p>
Because the browser already inserts quotation marks around <q> content automatically, adding your own produces doubled-up marks that look like: She said, ” “I’ll be there by noon.” “. The fix is to leave the quote marks out and let the browser generate them.
<p>She said, <q>I'll be there by noon.</q></p>
Mistake 3: Leaving tags unclosed inside a blockquote
<blockquote cite="https://example.com/article">
<p>Fortune favors the bold.
</blockquote>
The <p> element here is never closed before the parent <blockquote> closes, which is invalid, malformed markup that can confuse the DOM tree the browser builds. Always close every element you open.
<blockquote cite="https://example.com/article">
<p>Fortune favors the bold.</p>
</blockquote>
Best Practices
- Use
<blockquote>for extended, standalone quotations and<q>for short quotations embedded within a sentence. - Never type manual quotation mark characters inside
<q>— the browser inserts them for you. - Add a
citeattribute with the source URL whenever you know it, even though it isn’t shown on the page; it’s still useful metadata. - When you want the source visible to readers, add a separate
<footer>or paragraph containing a<cite>element or author name, rather than relying on the invisibleciteattribute. - Wrap even single-sentence quotations inside a
<p>element within<blockquote>so the structure stays valid and easy to extend. - Control indentation, borders, and quotation-mark styling with CSS rather than depending on default browser styling, which varies between browsers.
- Set an accurate
langattribute on the page or the quoted element so any locale-aware quotation marks render correctly.
Practice Exercises
- Write a
<blockquote>containing a two-sentence quotation from a book, including aciteattribute with a source URL and a visible<footer>with a<cite>naming the book title. - Write a single sentence that uses
<q>to quote something a friend said, without typing any quotation mark characters yourself. - Create a short example that correctly uses both the
citeattribute and the<cite>element in the same blockquote, and be ready to explain the difference between them.
Summary
<blockquote>is a block-level element for longer, standalone quotations; it is commonly indented by the browser’s default stylesheet.<q>is an inline element for short quotations within a sentence; browsers automatically add quotation marks around it via generated CSS content.- The
citeattribute on either element holds a source URL and is never displayed — it’s metadata only. - The
<cite>element is separate from theciteattribute and marks up the visible title of a referenced work, typically rendered in italics. - Never manually type quotation marks inside
<q>, and always close every tag you open, especially nested paragraphs inside<blockquote>. - Use CSS, not default browser styling, to control the visual appearance of quotations consistently.
