π What Is the quotes Property?
The quotes property in CSS defines the quotation marks used by the <q> HTML element and the pseudo-elementsopen-quote and close-quote.
Note
β Works with content: open-quote / close-quote
β Supports nested quotes (level 1, level 2...)
π¦ Basic Syntax
Syntax
quotes: "Β«" "Β»" "βΉ" "βΊ";Each pair defines:
β’ First pair β Level 1 quotes
β’ Second pair β Level 2 quotes (quotes inside quotes)
π How <q> Uses quotes
Default behavior
<q>Hello world</q>Browsers automatically add quotation marks around the text, and quotes controls what characters appear.
π Example: Custom Quote Style
Custom quotes
q {
quotes: "β" "β" "β" "β";
}Produces smart quotes like in books.
π Using with Pseudo-Elements
The content property can insert quotes viaopen-quote and close-quote.
Pseudo-element quotes
blockquote::before {
content: open-quote;
font-size: 2rem;
color: #ccc;
}
blockquote::after {
content: close-quote;
font-size: 2rem;
color: #ccc;
}π Nested Quotes
When quotes are nested, CSS automatically switches to the next pair.
Nested example
<q>Hello <q>inner quote</q> world</q>CSS
q {
quotes: "β" "β" "β" "β";
}Output becomes:βHello βinner quoteβ worldβ
π Removing Automatic Quotes
Remove quotes
q {
quotes: none;
}The <q> tag will no longer display quotation marks.
π Using quotes for Decorative Purposes
Decorative style
.fancy-quote::before {
content: open-quote;
color: gold;
font-size: 3rem;
}
.fancy-quote::after {
content: close-quote;
color: gold;
font-size: 3rem;
}π§ Browser Default Quote Styles
Browsers choose quotes based on user language, but you can override them.
| Language | Default Quotes |
|---|---|
| English | β β β β |
| French | Β« Β» βΉ βΊ |
| German | β β β β |
Note
Language-specific quotes
:lang(fr) q {
quotes: "Β«" "Β»" "βΉ" "βΊ";
}π Using open-quote & close-quote Manually
Manual insertion
.quote::before {
content: open-quote " Hello ";
}
.quote::after {
content: " world " close-quote;
}β οΈ Limitations & Gotchas
- β open-quote and close-quote only work with content
- β quotes must provide an even number of values
- β Not useful without <q> or pseudo-elements
- β Nested quote levels require multiple pairs
π₯ Summary
The quotes property controls how quotation marks appear around text, especially inside <q> elements or pseudo-elements usingopen-quote and close-quote. It is essential for proper typography, accessibility, and multilingual content.
Learn more β MDN Docs π