Sunday, February 15, 2009

" Hello World "

I really like those quotation mark images that now a days people are using.. you know, to define that this text is quotation.. As I was styling this blog I did some digging about how exactly people add those images.

I was pretty sure they use images inside <blockquote> but exactly how ?
do they add images manually or as a background image. It turns out authors prefer background images instead of adding image tags manually..

While searching things I came across this cool n simple way to add those quotes (check this) where there is one onload javascript which searches for <p> inside <blockquote> node n plugs quotation mark images on each side of it.

Its as simple as it sounds but I was not very useful for me. It was nothing like, you know, I was going to add quote for hundreds of time n thus need to run the script every time.. So I started playing around css. n after some time I came up with a solution that I want to share with you.

ACs are like computers - Both work fine until you open Windows!


Here, the good part is - quotes are floating.. they reposition themselves as inner text changes. Even shifts to next line if there's <br> in it.

/* CSS code for blockquote */
blockquote {
background: transparent url(start_quote_image_url) 1px 2px no-repeat;
padding: 5px 10px 0 35px;
margin: 5px 30px;
}
/* CSS code for p inside blockquote */
blockquote p {
background: transparent url(end_quote_image_url) 100% 0 no-repeat;
display: inline;
margin: 0;
padding: 3px 30px 0 0;
line-height: 22px;
}


So there you go.. You are now able to add quote images to <blockquote>

This css is not exactly perfect... It doesn't work in IE, if quote overflows to the second line. I'll explain that in my next post.

That's sad. But hey, It works in Firefox, Chrome and Safari.. :)

Update:
Please Note:
I've tweaked the CSS, so that it'll look differently (without quote images) in IE browsers. IE has some issues which I'll explain in my next post. So if you are using IE, may be its better if you shift to Firefox 3 asap.

4 comments:

  1. suppose I'm writing a post in the wordpress html editor. if, instead of using blockquote, i copy paste the code you have provided, will it work? I'll put in the requisite image url obv. And how does one demarcate the end of a CSS block of code? (like we have /blockquote in html)

    I'm sorry I have never done CSS editing before. But I think quotation marks images will look really attractive on the blog and want to use them!

    ReplyDelete
  2. i think there is a css editor for wordpress

    http://en.wordpress.com/products/custom-css/

    ReplyDelete
  3. @vedang in Edit html mode add this code within <style> </style> before your <blockquote> tag

    @CDK that's only preview. we needa pay to change css in wordpress

    ReplyDelete
  4. @praj he never mentioned he was using the free version...i thought vedang would only use the _complete_ version :P

    ReplyDelete