A café thrives on what its customers say about it, and a website also often needs to reproduce other people's words: a review, a remark from a member of the team, the title of a guide that recommends you. HTML has specific elements for each case, so that it's clear which text is a quotation and where it comes from. In this lesson you will learn to use blockquote for long quotations, q for short quotations within a sentence and cite for the titles of works. In the second part you will meet pre, the only element that preserves spaces and line breaks exactly as you type them (remember that the browser normally collapses them), and how to combine it with code to display code on a page. By the end, The Blue Cup will have customer reviews and a short recipe.

Contents

  1. Quoting content in HTML
  2. Block quotes: blockquote
  3. The cite attribute and attributing the quotation
  4. Inline quotations: q
  5. Titles of works: the cite element
  6. Which quotation element to use
  7. Preformatted text: pre
  8. Displaying code: pre + code
  9. Escaping < and >
  10. Project: The Blue Cup's reviews and recipe

Quoting content in HTML

When you reproduce the words of another person or another source, it's a good idea to mark them up so that:

  • Readers can clearly tell your text apart from the quoted text.
  • Screen readers and other tools can identify the quotation.
  • There is a record (where possible) of the original source.

HTML offers three elements related to quotations, which differ in the length and nature of what is quoted:

Element Type What it contains Default appearance
blockquote Block A long quotation, set apart from the text Indented on the left and right
q Inline A short quotation within a sentence Quotation marks added automatically
cite Inline The title of a work (book, guide, film…) Italics

Block quotes: blockquote

blockquote represents a section quoted from another source, long enough to take up its own block:

<blockquote>
  <p>The best croissant in the neighbourhood, and the coffee is always spot on.</p>
  <p>I don't have breakfast anywhere else now.</p>
</blockquote>
  • It's a block element: it starts on a new line and takes up the full available width.
  • By default, the browser gives it a margin on both sides, which sets it apart visually from the text.
  • It can contain paragraphs, lists or other content. The usual practice is to wrap the text in one or more p elements, as in normal text.
  • It doesn't add quotation marks: the indentation already shows that it's a quotation. If you want decorative quotation marks, they are added with CSS.

Use blockquote only for real quotations. Don't use it to indent your own text: that's a job for CSS.

The cite attribute and attributing the quotation

The cite attribute

blockquote (and q too) accepts the cite attribute, whose value is the URL of the source of the quotation:

<blockquote cite="https://reviews.example/the-blue-cup">
  <p>The best croissant in the neighbourhood, and the coffee is always spot on.</p>
</blockquote>
  • The browser doesn't display this attribute on the page: it's information for machines (search engines, scripts, tools).
  • So if the source matters to the reader, you should mention it in the visible text as well.

Attributing the quotation: who said it?

The name of the person who said the quotation doesn't go inside the blockquote, because it isn't part of what is quoted. It is written afterwards, in the normal text:

<blockquote cite="https://reviews.example/the-blue-cup">
  <p>The best croissant in the neighbourhood, and the coffee is always spot on.</p>
</blockquote>
<p>— Marta G., regular customer</p>

There is a more robust way of linking the quotation to its attribution: wrapping both in a figure element with its caption, figcaption.

<figure>
  <blockquote>
    <p>The best croissant in the neighbourhood.</p>
  </blockquote>
  <figcaption>— Marta G., regular customer</figcaption>
</figure>

This way the attribution is explicitly associated with its quotation. These two elements are covered in main and figure (Module 6); for now, we'll use a paragraph afterwards.

Inline quotations: q

q (quotation) marks a short quotation within a paragraph that doesn't need a block of its own:

<p>As our head baker says, <q>sourdough won't be rushed</q>.</p>
  • The browser adds the quotation marks automatically, and adapts them to the language of the document (lang="en"). That's why you shouldn't type them yourself: they would appear twice.
  • It also accepts the cite attribute with the URL of the source.
  • Don't use it for expressions in quotation marks that aren't quotations (irony, colloquial terms such as "bloom"): in those cases, just type the quotation marks by hand.
<!-- Incorrect: duplicated quotation marks -->
<p>She told us <q>“I’ll be back tomorrow”</q>.</p>

<!-- Correct -->
<p>She told us <q>I’ll be back tomorrow</q>.</p>

Titles of works: the cite element

Watch out for a common confusion: as well as the cite attribute (a URL), there is a cite element, with a different meaning. The cite element marks the title of a creative work: a book, a guide, a film, an article, a song, a television programme…

<p>We feature in the guide <cite>Neighbourhood Cafés 2026</cite>.</p>
<p>Our sponge cake is inspired by a recipe from <cite>The Big Book of Baking</cite>.</p>
  • By default it is displayed in italics.
  • According to the HTML specification, the cite element is for titles of works, not for people's names. The name of the person who wrote a review doesn't go in cite.
cite attribute cite element
Where it is written Inside <blockquote> or <q> As an element in its own right: <cite>…</cite>
Value/content A URL The title of a work
Visible on the page? No Yes (in italics)

Which quotation element to use

flowchart TD
    A{Are you reproducing words from another source?} -- No --> B{Are you mentioning the title of a work?}
    B -- Yes --> C["cite element"]
    B -- No --> D["Normal text"]
    A -- Yes --> E{Is it long or does it need its own block?}
    E -- Yes --> F["blockquote (with cite attribute if there is a URL)"]
    E -- No --> G["q inside the paragraph"]

Preformatted text: pre

In Headings and Paragraphs you saw that the browser collapses spaces and treats line breaks as a space. The pre element (preformatted text) is the exception: it displays the text exactly as it is written in the code.

<pre>
HOUSE COLD BREW
  Coarse-ground coffee   60 g
  Cold water            500 ml
  Rest in the fridge     12 h
</pre>

How pre behaves:

  • It preserves all spaces, tabs and line breaks. The columns in the example stay aligned.
  • By default it uses a monospaced font (every character takes up the same width), which is what makes it possible to align columns with spaces.
  • It doesn't wrap long lines: if a line doesn't fit, a horizontal scroll bar will appear or the text will overflow its container. Keep lines short.
  • The browser ignores a single line break immediately after <pre>, so that you can start the content on the next line. All other line breaks are preserved.
  • It can contain inline elements (strong, em, code…), but not block elements.

Be careful with code indentation: inside pre, the indentation you add to keep your HTML tidy will also be displayed.

    <body>
      <pre>
        Line one
        Line two
      </pre>
    </body>

Here both lines will appear with 8 spaces in front of them. That's why the content of a pre is usually written flush against the left margin, even if it breaks the indentation of the rest of the file.

When to use pre

Appropriate use Why
Blocks of source code Spaces and indentation are significant
Terminal or program output It is reproduced exactly as it is
ASCII art, data sheets aligned in plain text The alignment is part of the content
Poems with a special spatial layout The spaces have an artistic purpose

Don't use pre to get line breaks in normal text (that's what br or a new paragraph is for), nor to lay out data in columns that should be a table (Module 4) or a list. Bear in mind too that a screen reader reads the content of pre straight through: the visual alignment can't be perceived when listening.

Displaying code: pre + code

To display a block of code, the two elements are combined:

  • pre preserves the spaces and line breaks.
  • code, which you already know from Text Formatting Tags, indicates that the content is code.
<pre><code>body {
  color: navy;
}</code></pre>
  • code goes inside pre, never the other way round.
  • It's common to write <pre><code> on the same line and start the code straight afterwards, so as not to introduce unwanted spaces or line breaks.

Optionally, you can indicate the language with a class, a very widespread convention used by syntax highlighting libraries:

<pre><code class="language-css">p {
  margin: 0;
}</code></pre>

Escaping < and >

What if the code you want to display is HTML? If you write:

<pre><code><p>Hello</p></code></pre>

the browser won't display <p>Hello</p>: it will interpret <p> as a real tag and you will only see "Hello". For the symbols to be displayed as text, you have to escape them with entities:

Character Entity Reason
< &lt; less than: prevents it from being interpreted as the start of a tag
> &gt; greater than: the end of a tag
& &amp; The very symbol that entities start with
<pre><code>&lt;p&gt;Welcome to The Blue Cup&lt;/p&gt;</code></pre>

On screen you will see: <p>Welcome to The Blue Cup</p>.

For now, these three are enough. You will see exactly what entities are and which others exist in HTML Entities (Module 7).

Project: The Blue Cup's reviews and recipe

Customer reviews in index.html

Add a new section before "Contact":

    <h2>What our customers say</h2>
    <blockquote cite="https://reviews.example/the-blue-cup">
      <p>The best croissant in the neighbourhood, and the coffee is always spot on. I don't have breakfast anywhere else now.</p>
    </blockquote>
    <p>— Marta G., regular customer</p>

    <blockquote>
      <p>I did the sourdough bread-making workshop and I'm definitely coming back. They explain everything very patiently.</p>
    </blockquote>
    <p>— Andrew P., workshop participant</p>

    <p>We are also recommended in the guide <cite>Neighbourhood Cafés 2026</cite>.</p>
  • Each review is a blockquote with its text in a p. The first one indicates its source with the cite attribute (a fictional review website, on the reserved .example domain); the second was collected in person, so it has no URL.
  • The attribution goes outside the quotation, in a paragraph.
  • The guide is the title of a work: the cite element.

The people and the guide are fictional, like the rest of the project's data.

A short quotation in news.html

In the bread-making workshop news item, add this paragraph after the one about the places:

    <p>As our head baker says, <q>sourdough won't be rushed</q>.</p>

Check in the browser that the quotation marks appear on their own.

The recipe in preformatted text

At the end of news.html, add a news item with a recipe card in a pre. Notice that the content of the pre starts at column 0 of the file:

    <h2>A recipe for home: our cold brew</h2>
    <p>Many of you have asked us how we make our cold coffee. This is the recipe card we use in the bakery:</p>
<pre>
THE BLUE CUP COLD BREW
  Coarse-ground coffee   60 g
  Cold water            500 ml
  Rest in the fridge     12 h
  Filter                paper
</pre>
    <p>Serve it over ice and, if you like, with a splash of milk.</p>

Open the page: the recipe card appears in a monospaced font with its columns aligned, unlike the rest of the text. Try removing the pre (leaving the text inside a p): you will see everything run together on a single line, because the spaces are collapsed again.

Common Mistakes and Tips

  • Using blockquote to indent your own text: it's only for quotations; indentation is achieved with CSS.
  • Putting the attribution inside the blockquote: the name of the speaker isn't part of what is quoted.
  • Typing quotation marks inside q: the browser already adds them; they would appear twice.
  • Confusing the cite attribute (a URL, invisible) with the cite element (the title of a work, visible).
  • Using the cite element for people's names: it's for titles of works.
  • Indenting the content of pre so that the code "looks nice": the indentation will be displayed on screen.
  • Very long lines in pre: they cause horizontal scrolling, especially on mobile devices.
  • Forgetting to escape < and > when displaying HTML: the browser will interpret them as real tags and the example will disappear.
  • Tip: before using pre, ask yourself whether the spaces really are part of the content. If they aren't, you probably need paragraphs, a list or a table.

Exercises

Exercise 1. Mark up each case correctly with blockquote, q, the cite element or nothing:

  1. A long paragraph from a review published in a food magazine.
  2. In a news item: The mayor said that "the neighbourhood needed a place like this".
  3. The name of the magazine: Urban Flavours.
  4. The expression "speciality coffee", written in quotation marks to make it stand out.
  5. The name of the person who wrote the review.

Exercise 2. This fragment should display the HTML code of a link on screen, with its indentation. Correct it:

<code><pre>
    <a href="menu.html">See the menu</a>
</pre></code>

Exercise 3. Write an "Opening hours" section for contact.html (just the body fragment) that displays this timetable aligned in columns in a pre: Counter from 8:00 to 20:00, Bread sales from 8:00 to 14:00 and Workshop on the first Saturday from 10:00 to 13:00. Then briefly explain which other HTML element would be more suitable for this data and why.

Solutions

Solution 1.

<!-- 1, 3 and 5 -->
<blockquote cite="https://flavours.example/the-blue-cup-review">
  <p>The Blue Cup has achieved something difficult: speciality coffee without the pretension…</p>
</blockquote>
<p>— Laura M., in <cite>Urban Flavours</cite></p>

<!-- 2 -->
<p>The mayor said that <q>the neighbourhood needed a place like this</q>.</p>

<!-- 4: not a quotation; quotation marks typed by hand -->
<p>We work with “speciality coffee” from small producers.</p>

The person's name (5) goes in the attribution as normal text; the title of the magazine (3), in the cite element; the URL of the source, in the cite attribute of the blockquote.

Solution 2. There are three problems: code must go inside pre (not the other way round), the <a> tags must be escaped so that they are displayed as text, and the line break after <pre> and the indentation would be displayed as they are:

<pre><code>    &lt;a href="menu.html"&gt;See the menu&lt;/a&gt;</code></pre>

Now you will see <a href="menu.html">See the menu</a> indented by four spaces, which in this case are intentional.

Solution 3.

    <h2>Opening hours</h2>
<pre>
Counter           8:00 - 20:00
Bread sales       8:00 - 14:00
Bread workshop   10:00 - 13:00 (first Saturday)
</pre>

It works visually, but this data has the structure of a table (service, opening time, closing time), which is what you will learn about in Module 4. A table would let screen readers relate each time to its service, something that alignment with spaces doesn't convey. Another valid alternative, with what you already know, would be a description list (dl): the service as the dt and the times as the dd.

Conclusion

You now know how to reproduce other people's words with the right element: blockquote for long quotations (with the cite attribute for its URL and the attribution outside the quotation), q for short quotations that the browser puts in quotation marks by itself, and the cite element for titles of works. You have also mastered pre, which preserves spaces and line breaks, its combination with code for displaying code and the need to escape <, > and &. The Blue Cup now shows customer reviews on its home page, a quotation from its baker and a recipe in news.html. So far you have used elements that mean something specific; in the next lesson, Block and Inline Elements: div and span, you will understand the model that explains why some elements take up the whole line and others don't, and you will meet the two generic containers used to group content when no other element fits.

HTML Course

Module 1: Introduction to HTML

Module 2: Text Formatting in HTML

Module 3: Links and Media in HTML

Module 4: Tables in HTML

Module 5: Forms in HTML

Module 6: HTML5 Semantic Elements

Module 7: Advanced HTML Techniques

Module 8: Integrating HTML and CSS

Module 9: Responsive Web Design

Module 10: Best Practices and Accessibility

Module 11: Project: Building a Complete Website

© Copyright 2026. All rights reserved