You may have been made familiar with CSS generated content by reading blogs such as this one: Automatically Numbering Non-Lists...Or maybe not, whatever the case, there's other content generation we can do with CSS, like adding quotes.
I usually would just add a blockquote to my markup and add CSS generated content :before and :after my blockquote, like so:
blockquote:before {
content: "“";
}
blockquote:after {
content: "”";
}
And this works just fine; in fact, I might even argue that despite this blog post, this blockquote content approach may very well be the better approach. But, we're going to look at something new anyways; The
CSS Quotes property.
Essentially, all this thing does is allow you to define your entire hierarchy of nested quotes to use throughout your site, and then call them in a nice, easy way. It's pretty straight forward, simply select your blockquote (and in my case, I'm also going to select the q element), and define your hierarchical quotes in left/right order:
blockquote, q {
quotes: "1" "1b" "2" "2b" "3" "3b";
}
In my example, for the sake of illustration, I'm going to use a numbering system 1, 1b (1 for left and 1b right quotes), and continue that through to a 3rd level. I'm also going to add some styling to call out the 3 levels of quotes that I'm going to have in my HTML:
This is a super important quote.
Here is a sub quote
within my big quote.
And now some lorem ipsum...
Now for my expanded CSS; you can see that to reference my quotes as defined, I'm going to use the :before and :after classes, and add my content, but instead of adding a string of "1", I can just say open-quote (and close-quote for the :after). This is possible because I've defined my quote content hierarchy in my quotes property:
blockquote {
font-family: sans-serif;
margin: 1em;
}
blockquote, q {
quotes: "1" "1b" "2" "2b" "3" "3b";
}
q {
background: #fcc;
padding: 3px;
border-radius: 3px;
}
blockquote:before,
blockquote:after {
content: open-quote;
font-size: 2em;
font-weight: bold;
color: orange;
}
q:before,
q:after {
content: open-quote;
font-weight: bold;
color: blue;
}
blockquote:after,
q:after {
content: close-quote;
}
q q:before,
q q:after {
font-weight: normal;
color: green;
}
The end result will look like so:
I added a pink background around my inner q element to illustrate that our added quotes actually are included INSIDE our elements. Anyhow, sort of neat. Below is the full code...
Final Thoughts
You could include the cite element in this discussion, and there are obviously a myriad of ways to render this stuff, so I'll leave it to you how you want to do that - but I think Smashing Magazine has a nice write up to take it from here.