two years agoInline image quotes
I have been meaning to write about this technique for some time now. The aim is a block quote looking something like this, with speech marks at the front and termination of the text but without the nastiness of inline images.
To be a valid blockquote there must be an inner block level containing element such as a paragraph or div. You can use this to your advantage in order to apply the two background images. The top one you can apply to the block quote itself using a text indent to make space for the image.
blockquote {
text-indent: 25px;
background: url(quotes1.png);
background-position: 0 2px;
background-repeat: no-repeat;
}
For the second image on the bottom right, you are going to be doing something a bit clever with the containing paragraph. Set it to be display inline, set padding on the right to be a bit more than the width of your image, then put the background image of the end quote mark on the bottom right of the paragraph.
blockquote p {
display: inline;
margin: 0;
padding-right: 24px;
background: url(quotes2.png);
background-position: bottom right;
background-repeat: no-repeat;
}
And there you have it, inline image quotes.
35 comments
Comments are closed.

I can't remember where I saw it (or even if I did - it may have been a dream) but I tend to use the following method:
I set the blockquote to display: list-item and give it a list-style-image with the opening quote.
Then I apply padding to the right hand side of the blockquote and apply a background of the second quote, positioned bottom-right.
You may or may not have to mess around with list-style-position - I can't remember.
Anyway, this lets you use multiple block level elements inside the blockquote.
Pete Lambert 22nd November 2006 11:16
Very nice. I use very nearly the same system myself on our new site, with one modification (read: compromise).
To allow multiple paragraphs to be quoted at once, I have the closing quote styled using
blockquote p:last-childas the selector. That doesn't work in Internet Explorer, but you still get the open quote so I'm happy with it.I'm considering expanding it a bit, perhaps using
blockquote > *:last-childto be more flexible, and then have override rules for situations such asblockquote > table:last-childwhere I wouldn't want to indent the right hand edge, and instead push the quote mark down below the table (or even perhaps useblockquote > table:last-child::after).I love CSS.
Pete's method sounds interesting though,
list-itemrelated styling is never in the front of my mind but that sounds pretty neat.Ben Ward 22nd November 2006 11:42
Ben Darlow 22nd November 2006 14:20
A slight variation. I've got several paragraphs within a single blockquote, so rather than each one of them having an endquote I've changed the rule to only apply to the last-child. I've also removed the inline display mode, as the technique is highly dependent upon your image size being smaller than the actual text line height (rather than line-height) if you use inline. Plus I think it works slightly better for my layout if the final closing quote is effectively right-aligned.
Doesn't work in IE7 though (no last-child selector? gasp!).
Ben Darlow 22nd November 2006 14:32
Andrea 23rd November 2006 10:28
Finally! I hate seeing blockquotes with only opening quotes, because that's wrong grammatically and incredibly distracting. I keep waiting for that closing quote.
The better way to do it would be to put the beginning image on the paragraph and the ending image on the blockquote. New paragraphs within a quote are started by reopening the quotes, but only the last paragraph would have the closing quote. The closing quote may not sit at the end of the line, but it's better than forever waiting for an ending that never happens.
Rebeka 24th November 2006 15:58
There are some very interesting ideas there, I especially like the display as list item one, though I am wary of using last child because of browser issues, though it would be great if worked reliably.
I have published an update to this post here: http://natbat.net/2006/11/22/blockquotesagain/ where I try out various ideas on multiple paragraphs, not grammatically correct perhaps but it is just an experiment.
Regarding swapping the images around Rebeka, the main point with this technique is that it works well on single paragraph quotes where the two quotemarks appear as inline to the text, though i do see your point about multiple paragraphs and the gramatics of it.
natbat 24th November 2006 19:29
annie 25th November 2006 01:06
Verdure Thought 27th November 2006 10:19
Vesa Virlander 27th November 2006 10:47
Another elegant solution is to use the :before and :after pseudo-elements.
blockquote:before { content: url(quotes1.png); } blockquote:after { content: url(quotes2.png); }Work fine with Firefox and Opera but unfortunately this is not supported by IE (not even IE7).
Ciprian Amariei 27th November 2006 22:16
lomig 28th November 2006 11:51
natbat 28th November 2006 13:08
natbat 28th November 2006 13:19
Steve 28th November 2006 14:31
natbat 28th November 2006 14:40
lomig 28th November 2006 14:51
<p>element inside of a<strong>element (which isn't valid since<strong>is an inline element). Also, the<strong>element is being closed before the<p>element. Both of these issues combined are probably causing your problem.Thomas Higginbotham 28th November 2006 17:23
hi thomas,
thanks a lot...it seems to be working. Now i only have to fix my transparency problem, and i'll be ok = thanks to all of you for your kind, quick and respectfull answers to a newbie, bad english speaking french guy
regards........Lomig
lomig 28th November 2006 21:11
anna 4th December 2006 14:15
hi,
there seems to be a problem : everything is fine in Mozilla, but not in IE 6 !
do you know if there"s a way to ged rid of that pb ? (except using mozilla ;) )
lomig
lomig 5th December 2006 22:08
vlado 7th December 2006 11:53
fabio 29th December 2006 12:46
JasonM 1st February 2007 10:56
Jan 3rd February 2007 17:20
vlado 21st February 2007 18:19
3DCADResources 22nd February 2007 14:21
Marshall 4th March 2007 03:38
decimus 7th August 2007 12:40
I was reading most of the entries with interest and I had a good idea of the issue but my problem is I need to put this in a template so any non CSS person can just copy paste things also there is a slight problem... I need to add the name of the person quoted from at the end of the paragraph after the closing quotes and after inside paragraph. Am I asking too much? :)
I am getting used to this CSS...
gultekin 6th September 2007 16:38
I was looking for some tutorials on the net and dont know why but all tutorials ive found was about inline quotes ;))))
regards!
dotacje unijne 10th January 2008 02:32
Wayne 3rd February 2008 19:03
btw, I've enabled this on my site and I modified it some so that the whole comment block would be indented (that's more visually appealing to me personally) by adding a margin: 25px to the main blockquote piece. I think that caused the right side quote to not display, because it's not honoring the margin: 0 line. When I check out the resulting CSS (via IE dev toolbar) on my page, the P tag doesn't have any margin lines. Checking out YOUR page, it has all the margin and margin- lines in the P tag.
Do you have a suggestion as to how I can indent the entire quote block, and still have the inline quotemark images?
This post has a blockquote as the second paragraph, if you need a working reference.
Thanx much
Wayne 3rd February 2008 19:43
Jonathan 13th March 2008 20:52
Marcus 21st March 2008 16:39