🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.
REFERENCEhtml

html Documentation

LOADING ENGINE...

<q>

AI & DATA SCIENCE // q-tag

The <q> element marks a short inline quotation; browsers automatically surround its content with quotation marks.

Syntax

She said <q>I'll be there by noon.</q>

Deep Dive Course

**`<q>`** is the inline counterpart to `<blockquote>` — meant for short quotations that flow within a sentence, rather than a standalone block. Browsers automatically render the appropriate quotation marks (and can even use language-specific styles, like «guillemets» for some locales, based on the `lang` attribute) around its content, so you should NOT manually type quotation marks inside a `<q>` — that would produce doubled-up marks.

1Understanding <q>

`<q>` is the inline counterpart to <blockquote> — meant for short quotations that flow within a sentence, rather than a standalone block. Browsers automatically render the appropriate quotation marks (and can even use language-specific styles, like «guillemets» for some locales, based on the lang attribute) around its content, so you should NOT manually type quotation marks inside a <q> — that would produce doubled-up marks.

💡

Don't add your own " characters inside <q> — the browser inserts them via CSS (the ::before/::after pseudo-elements with the 'quotes' property), so typing your own results in redundant nested quote marks.

editor.html
<p>As the saying goes, <q>actions speak louder than words</q>.</p>
localhost:3000

2Practical Example

Here is a real-world application of <q> showing how it is used in production HTML.

editor.html
<!-- The optional cite attribute records the source URL (not displayed) -->
<p>The article stated <q cite="https://example.com/article">sales grew 40% this year</q>.</p>
localhost:3000

3Best Practices

Follow these guidelines when working with <q>:

1. Use <q> for short quotes that fit inline within a sentence

2. Never manually add quotation mark characters inside <q> — let the browser render them

3. Use <blockquote> instead for longer, standalone quotations

⚠️

Tip: Don't add your own " characters inside <q> — the browser inserts them via CSS (the ::before/::after pseudo-elements with the 'quotes' property), so typing your own results in redundant nested quote marks.

editor.html
<p>As the saying goes, <q>actions speak louder than words</q>.</p>
localhost:3000

Examples

Example 01Basic Usage
<p>As the saying goes, <q>actions speak louder than words</q>.</p>
Example 02Advanced Example
<!-- The optional cite attribute records the source URL (not displayed) -->
<p>The article stated <q cite="https://example.com/article">sales grew 40% this year</q>.</p>

Best Practices

  • Use for short quotes that fit inline within a sentence
  • Never manually add quotation mark characters inside — let the browser render them
  • Use
    instead for longer, standalone quotations

Interview Question

Why shouldn't you manually type quotation marks inside a <q> element?

Hint: Think about how the browser generates the visible quote marks.

Browsers automatically insert opening and closing quotation marks around <q> content via built-in CSS (the ::before and ::after pseudo-elements paired with the 'quotes' property), which can even vary by language via the lang attribute. If you also type literal " characters inside the <q>, you end up with visibly doubled quotation marks, like “"actions speak louder"”.

Exercises

EasyPractice using <q> in a real scenario.
View Solution
<p>As the saying goes, <q>actions speak louder than words</q>.</p>

Frequently Asked Questions

Why shouldn't you manually type quotation marks inside a <q> element?

Browsers automatically insert opening and closing quotation marks around content via built-in CSS (the ::before and ::after pseudo-elements paired with the 'quotes' property), which can even vary by language via the lang attribute. If you also type literal " characters inside the , you end up with visibly doubled quotation marks, like “"actions speak louder"”.

Related Functions

blockquote-tagcite-tag