CSS quotes Property
The CSS quotes property specifies the quotation marks used when CSS generates opening and closing quotation characters.
It works with the content property and the open-quote, close-quote, no-open-quote, and no-close-quote keywords. You can define quotation mark pairs for different nesting levels, use language-appropriate punctuation, or prevent generated quotation marks from appearing.
quotes Syntax
The quotes property accepts auto, none, or one or more pairs of strings. Each pair contains an opening quotation mark followed by its corresponding closing quotation mark.
Basic Syntax
selector {
quotes: auto;
}
Common Values
q {
quotes: auto;
}
q {
quotes: none;
}
q {
quotes: '"' '"';
}
q {
quotes: "“" "”" "‘" "’";
}
q {
quotes: "«" "»" "‹" "›";
}
CSS-Wide Keywords
q {
quotes: initial;
}
q {
quotes: inherit;
}
q {
quotes: unset;
}
q {
quotes: revert;
}
q {
quotes: revert-layer;
}
Quotation mark strings must be provided in opening and closing pairs. Each additional pair defines the characters used at another nesting level.
Property Values
| Value | Description |
|---|---|
auto |
Uses quotation marks selected by the browser according to the element's language. This is the initial value. |
none |
Prevents the open-quote and close-quote keywords from generating visible quotation marks while preserving nesting behavior. |
<string> <string> |
Defines an opening and closing quotation mark pair. |
<string> <string> <string> <string> |
Defines two pairs of quotation marks for different nesting levels. |
initial |
Resets the property to auto. |
inherit |
Uses the computed value from the parent element. |
unset |
Inherits the value from the parent because the property is inherited. |
revert |
Reverts the property according to CSS cascade origin rules. |
revert-layer |
Reverts the property according to CSS cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | All elements |
| Computed value | As specified, with relative URLs not applicable |
| Animation type | Discrete |
| Percentages | Not applicable |
Valid Values
q {
quotes: auto;
}
q {
quotes: none;
}
q {
quotes: "“" "”";
}
q {
quotes: "«" "»" "‹" "›";
}
Invalid Values
q {
quotes: normal;
}
q {
quotes: "“";
}
q {
quotes: "“" "”" "‘";
}
q {
quotes: 20px;
}
q {
quotes: open-quote close-quote;
}
Custom quotation strings must be supplied in complete pairs. The open-quote and close-quote keywords belong to the content property, not the quotes property.
How It Works
The quotes property defines the characters available for generated quotation marks. The content property determines when those characters appear.
Step 1: Define the Quotation Marks
q {
quotes: "“" "”";
}
Step 2: Generate the Opening Mark
q::before {
content: open-quote;
}
Step 3: Generate the Closing Mark
q::after {
content: close-quote;
}
Complete Example
q {
quotes: "“" "”";
}
q::before {
content: open-quote;
}
q::after {
content: close-quote;
}
HTML Example
<p>The instructor said <q>CSS controls presentation.</q></p>
The generated quotation marks appear around the text contained in the <q> element.
Important Distinction
The quotes property does not insert quotation marks by itself. Generated content must use the appropriate quotation keywords, either through browser default styles or author-defined CSS.
Defining Quotation Mark Pairs
Each pair in the quotes property consists of two CSS strings: the opening mark and the closing mark.
Curly Double Quotation Marks
q {
quotes: "“" "”";
}
Straight Double Quotation Marks
q {
quotes: '"' '"';
}
Angle Quotation Marks
q {
quotes: "«" "»";
}
Two Levels of Quotation Marks
q {
quotes: "“" "”" "‘" "’";
}
The first pair is used for the outer quotation level. The second pair is used for the next nested level.
Three Levels of Quotation Marks
q {
quotes: "“" "”" "‘" "’" "«" "»";
}
Additional pairs can be defined when more nesting levels require distinct quotation marks.
Using the Last Available Pair
If the nesting depth exceeds the number of defined pairs, the browser continues using the last pair for deeper levels.
Important Consideration
CSS strings can contain Unicode quotation characters directly or use escaped character codes. Choose characters appropriate for the document's language and typography.
Nested Quotation Marks
Nested quotations use different pairs of quotation marks according to their depth.
CSS Example
q {
quotes: "“" "”" "‘" "’";
}
q::before {
content: open-quote;
}
q::after {
content: close-quote;
}
HTML Example
<p>
<q>The developer said <q>Use semantic HTML</q> during the lesson.</q>
</p>
The developer said
Use semantic HTML
during the lesson.
The outer quotation uses double curly quotation marks. The nested quotation uses single curly quotation marks.
Quotation Depth
The browser tracks quotation depth when processing open-quote and close-quote. Opening a quotation increases the depth, while closing one decreases it.
Important Consideration
Use nested <q> elements to represent quotations within quotations. This preserves the meaning of the content while allowing CSS to control the punctuation.
Automatic Quotation Marks
The auto value allows the browser to choose quotation marks appropriate for the element's language.
Basic Example
q {
quotes: auto;
}
English Quotation
<p lang="en"><q>This is an English quotation.</q></p>
French Quotation
<p lang="fr"><q>Ceci est une citation.</q></p>
The browser can select quotation characters based on the language information supplied by the lang attribute.
Browser Default Styles
Browsers commonly generate quotation marks for the HTML <q> element through their default styles. The exact characters can vary with language and browser implementation.
When to Use auto
Use auto when language-aware quotation marks are preferred and there is no requirement to enforce a specific pair of characters.
Important Consideration
The auto value depends on language information and browser support. Provide accurate lang attributes to help browsers select appropriate punctuation.
Suppressing Quotation Marks
The none value prevents generated quotation characters from appearing while allowing quotation depth to be tracked.
Using none
q {
quotes: none;
}
When the browser processes open-quote and close-quote, no visible quotation characters are generated.
Using no-open-quote
.quotation::before {
content: no-open-quote;
}
The no-open-quote keyword increases quotation depth without displaying an opening quotation mark.
Using no-close-quote
.quotation::after {
content: no-close-quote;
}
The no-close-quote keyword decreases quotation depth without displaying a closing quotation mark.
Empty Quotation Strings
q {
quotes: "" "";
}
Empty strings also produce no visible quotation characters, but they explicitly define an empty opening and closing pair instead of using the none keyword.
Important Distinction
quotes: none is a value of the quotes property. The no-open-quote and no-close-quote keywords are values used with the content property.
Language-Specific Quotation Marks
Different languages and typographic conventions use different quotation characters. CSS allows you to define these explicitly when necessary.
English-Style Quotation Marks
q:lang(en) {
quotes: "“" "”" "‘" "’";
}
French-Style Quotation Marks
q:lang(fr) {
quotes: "«" "»" "‹" "›";
}
German-Style Quotation Marks
q:lang(de) {
quotes: "„" "“" "‚" "‘";
}
Using Language Attributes
<p lang="en">
<q>English quotation</q>
</p>
<p lang="fr">
<q>Citation française</q>
</p>
<p lang="de">
<q>Deutsches Zitat</q>
</p>
The :lang() pseudo-class matches elements according to their language, including language inherited from an ancestor.
Spacing Around Quotation Marks
Some typographic conventions require spaces around quotation marks. When exact spacing matters, include the appropriate characters in the quotation strings.
q:lang(fr) {
quotes: "«\202F" "\202F»" "‹\202F" "\202F›";
}
The \202F escape represents a narrow no-break space, which is used in some French typographic conventions.
Important Consideration
Quotation conventions can vary by region and publication style. Use auto when browser-selected punctuation is sufficient, or define explicit pairs when a particular style is required.
quotes Example
The following example demonstrates custom quotation marks and nested quotations using the quotes property.
HTML Example
<div class="quotes-demo">
<p><q>CSS controls the visual presentation of HTML.</q></p>
<p><q>The instructor said <q>Use semantic elements</q> during the lesson.</q></p>
</div>
CSS Example
.quotes-demo {
padding: 16px;
border: 1px solid #cbd5e1;
background-color: #f8fafc;
}
.quotes-demo q {
quotes: "“" "”" "‘" "’";
}
.quotes-demo q::before {
content: open-quote;
}
.quotes-demo q::after {
content: close-quote;
}
.quotes-demo p {
margin: 0 0 12px;
}
.quotes-demo p:last-child {
margin-bottom: 0;
}
CSS controls the visual presentation of HTML.
The instructor said
Use semantic elements
during the lesson.
The first quotation uses double curly quotation marks. The nested quotation in the second paragraph uses single curly quotation marks.
Changing to Angle Quotation Marks
.quotes-demo q {
quotes: "«" "»" "‹" "›";
}
This replaces the curly quotation marks with angle quotation marks at both nesting levels.
Removing Generated Quotation Marks
.quotes-demo q {
quotes: none;
}
The quotation text remains visible, but the generated opening and closing quotation characters are suppressed.
Accessibility Considerations
Quotation marks are punctuation, but quoted content also has semantic meaning. CSS should not be the only method used to identify quotations.
Use Semantic HTML
Use the <q> element for short inline quotations and the <blockquote> element for extended quotations.
Do Not Rely Only on Generated Content
Generated quotation marks may be handled differently by screen readers and other assistive technologies. Preserve quotation semantics in the HTML.
Maintain Readable Typography
Choose quotation characters that are visually distinguishable and appropriate for the document's language.
Provide Language Information
Use accurate lang attributes so browsers and assistive technologies can interpret language-specific punctuation and text correctly.
Avoid Decorative Confusion
Large decorative quotation marks should not obscure the quoted text or interfere with reading order.
Important Consideration
The quotes property controls visual punctuation. It does not replace the semantic meaning provided by HTML quotation elements.
Common Mistakes
Expecting quotes to Generate Characters by Itself
.quotation {
quotes: "“" "”";
}
This defines quotation characters but does not insert them. Generated content must use open-quote and close-quote.
Providing an Incomplete Pair
q {
quotes: "“";
}
Each opening quotation string must have a corresponding closing quotation string.
Using an Odd Number of Strings
q {
quotes: "“" "”" "‘";
}
Custom quotation strings must be supplied in complete pairs.
Using content Keywords as quotes Values
q {
quotes: open-quote close-quote;
}
The open-quote and close-quote keywords belong to the content property.
Adding Literal Quotation Marks and Generated Quotes
<q>"Quoted text"</q>
If the browser also generates quotation marks for the <q> element, the result may contain duplicate punctuation.
Ignoring Nested Quotation Levels
Using only one pair causes deeper quotation levels to reuse the same characters. Define additional pairs when distinct nested punctuation is required.
Ignoring Language Conventions
Quotation characters and spacing vary between languages. Use appropriate punctuation or the auto value.
Confusing none With Removing Quoted Content
The none value suppresses generated quotation marks. It does not remove the quoted text or change its HTML semantics.
Important Considerations
Keep the following points in mind when using quotes:
- It defines quotation characters for CSS-generated content.
- Its initial value is
auto. - The property is inherited.
- It applies to all elements.
autoselects quotation marks based on language and browser behavior.nonesuppresses generated quotation characters.- Custom quotation characters are defined as pairs of CSS strings.
- The first string in each pair is the opening quotation mark.
- The second string in each pair is the closing quotation mark.
- Additional pairs define punctuation for deeper nesting levels.
- The last defined pair is reused when nesting exceeds the available pairs.
- The property does not generate quotation marks by itself.
content: open-quotegenerates an opening quotation mark.content: close-quotegenerates a closing quotation mark.no-open-quoteincreases nesting depth without displaying a mark.no-close-quotedecreases nesting depth without displaying a mark.- Quotation depth is tracked when generated quotation keywords are processed.
- Custom strings may contain Unicode quotation characters.
- CSS character escapes can be used for special punctuation and spacing.
- The
:lang()pseudo-class can apply language-specific quotation styles. - Accurate HTML
langattributes support language-aware punctuation. - Browsers commonly generate quotation marks for the
<q>element. - Avoid adding literal quotation marks inside
<q>when generated marks are already present. - Use semantic HTML quotation elements rather than relying only on CSS.
- Generated punctuation may be interpreted differently by assistive technologies.
- Test nested quotations and multilingual content when using custom styles.
Browser Support
The CSS quotes property is Baseline Widely available and is supported in current versions of major browsers.
The auto and none values, custom quotation pairs, and generated quotation keywords are broadly supported. Exact language-specific punctuation may vary according to browser implementation and language information.
For current compatibility information, visit Can I Use? and search for quotes.
Test custom quotation styles when consistent punctuation is important across browsers or languages.
Specifications
The quotes property is defined in CSS Generated Content Module Level 3.
CSS Generated Content Module Level 3
The specification defines automatic quotation marks, custom quotation pairs, and the handling of quotation depth in generated content.
For additional documentation and examples, consult MDN Web Docs.
