HTML Reference Β· Inline Text
The <q> element
Reference for the HTML <q> element: short inline quotations, automatic quotation marks, the cite attribute, language-aware quotes and technical details.
The <q> element marks a short quotation that sits inside a line of text, such as a few words someone said or wrote. Browsers add the quotation marks for you, so you type only the quoted words. For a quotation that forms its own paragraph or block, use <blockquote> instead.
<p>The guide's only advice was <q>pack less than you think</q>.</p>
Try it
A <q> nested inside another <q> gets the secondary style of quotation marks (single quotes in English). The marks also follow the lang of the text, so French and German quotes look different from English ones.
Attributes
| Attribute | Values | Description |
|---|---|---|
cite |
A valid URL | The address of the source document or message the quotation comes from. Browsers do not display it; scripts and tools can read it. |
The element also accepts the global attributes.
Usage notes
- Don't type the quotation marks yourself. The browser inserts them through the CSS
quotesproperty and the::beforeand::afterpseudo-elements. Adding your own produces doubled marks. - Use it only for real quotations. Sarcastic "scare quotes", titles of works, or words you are talking about are not quotations from a source. Type ordinary quotation marks for those, or use
<cite>for a work's title. - Short quotes only. If the quotation is a full paragraph or several sentences shown as a block, switch to
<blockquote>. citeis invisible. If the reader should see the source, add a visible link or a<cite>element near the quotation.- Copying text. The generated quotation marks are not part of the document text, so some browsers leave them out when a user copies the passage.
- Styling. Change the marks with CSS, for example
q { quotes: "Β«" "Β»" "βΉ" "βΊ"; }. Settingquotes: noneremoves them.
Technical summary
| Content categories | Flow content, phrasing content, palpable content |
| Permitted content | Phrasing content |
| Tag omission | None; both the start and end tags are required |
| Permitted parents | Any element that accepts phrasing content |
| Implicit ARIA role | generic |
| DOM interface | HTMLQuoteElement |
| Default display | inline (with quotation marks added before and after) |
Browser support
Supported in every browser, including automatic language-specific quotation marks.
Related
<blockquote>β a quotation shown as its own block<cite>β the title of a quoted work<em>β stress emphasis- Lesson: Quotations, Citations and Abbreviations
- Lesson: Formatting Text