treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Simple and Nice Blockquote Styling

Last updated on:

The blockquote displays in standards-compliant browsers with the "big quotes before" effect, and in IE with a thick left border and a light grey background.
Unlike other blockquote techniques, this style does not require a nested block-level element (like p). As such, it turns a paragraph into an inline-styled element to keep the content from dropping below the quote.

blockquote {
background:#f9f9f9;
border-left:10px solid #ccc;
margin:1.5em 10px;
padding:.5em 10px;
quotes:"\201C""\201D""\2018""\2019";
}
blockquote:before {
color:#ccc;
content:open-quote;
font-size:4em;
line-height:.1em;
margin-right:.25em;
vertical-align:-.4em;
}
blockquote p {
display:inline;
}

Example

Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.

Reference URL

View Comments

Comments

  1. Permalink to comment#

    the only thing i would like for this would be a closing quote at the end.

  2. Permalink to comment#

    scratch that..

  3. Permalink to comment#

    What will this look like?

  4. Thanks very much for this!

  5. Personally, I think that the use of the vertical line *and* the quotation mark is redundant, since they both signify the same thing.

  6. Permalink to comment#

    This doesn’t seem to work in chrome/safari.

  7. Permalink to comment#

    … If you want it to work in Safari/Chrome.

    blockquote:before {

    content:”\201C”;

    }

    blockquote:after {

    content:”\201D”;

    }

  8. Wolf
    Permalink to comment#

    Using multiple blockquotes one after another seems to result in the first instance having a double quote before but every subsequent instance having only a single quote before (in Firefox). Why would this be?

  9. Permalink to comment#

    what would the
    code for the closing quote be?

  10. Permalink to comment#

    sorted

    blockquote:after {color:#B2AFCD;content:close-quote;font-size:4em;line-height:.1em;margin-right:.25em;vertical-align:-.4em;}

    just gotta paly with the spac a bit :)

  11. Permalink to comment#

    ‘Scuse my appalling spelling!

    final

    blockquote:after {color:#B2AFCD;content:close-quote;font-size:4em;line-height:.1em;margin-left: .20em;vertical-align:-.4em;}

    Thanks for great tips Chris :)

  12. Charlie
    Permalink to comment#

    What’s the:

    quotes:"\201C""\201D""\2018""\2019";

    for on blockquote?
    You don’t seem to need it if you specify \201C and \201D on :before and :after.

    Am I missing something?

  13. Hey all, as the original snippet submitter, I just wanted to follow up and address some of the weaknesses mentioned in the comments. Here is some css that I think is an improvement:

    
    blockquote{background:#f9f9f9;border-left:1em solid #eee;margin:1.5em 1em;padding:.5em 1em;quotes:"\201C""\201D";}
           blockquote:before{color:#808080;content:open-quote;font-size:4em;line-height:.1em;margin-right:.25em;vertical-align:-.4em;}
           blockquote :first-child{display:inline;}
           blockquote :last-child{margin-bottom:0;}
    
  14. jenn
    Permalink to comment#

    This doesn’t seem to work in chrome.

  15. Very useful reference! If anyone is wondering why only their first blockquote has the double quote marks but the following ones don’t, you just need to add:

    blockquote:after {
    content: no-close-quote;
    }

  16. Permalink to comment#

    Hi,

    How to add a box shadow ?
    Thanks

  17. Pretty easy and cool! Thanks Chris!

  18. Permalink to comment#

    Thanks man, it helped me alot :)

  19. Derek

    Anyone know how to modify the css so that there is a space between paragraphs in a block quote? Thanks for any help.

Leave a Comment

Use markdown or basic HTML and be nice.