Image Caption Not Working? The CSS Solution

by Yan Susanto

You have probably known by now that one of the latest addition to WP 2.6 – among other great features – is the Image Caption – a little description of the image derived from the ALT text.

The theory is ALT text to your image is what you describe the image to the Search Engines. For SEO purpose, it should always be optimized with the use of proper keywords.

Well, to tell you the truth, I’m not too fond of image caption as I always think the image is better off without it and to make the matter worst, what I see on the editor is not what I see on preview.

I assume that to the majority of us, the image caption will not display properly the way it should on the published post. Since it’s one of the default features that comes with the package, I was just wondering why there isn’t any official guide on how to make the caption work – properly.

So in the spirit of sharing, I’d like to share with you the solution to fix it by adding some CSS elements to control the visual appearance of your image and its caption.

Image Caption at Work

This is Image Caption

This is Image Caption

Adding CSS Style to Your Stylesheet


/* IMAGE CAPTION
/* ----------------------------------------------*/

.wp-caption {
      border: 1px solid #ddd;
      text-align: center;
      background-color: #f3f3f3;
      padding-top: 4px;
      margin: 10px;
      /* For rounded corner */
      -moz-border-radius: 3px;
      -khtml-border-radius: 3px;
      -webkit-border-radius: 3px;
      border-radius: 3px;
      }

.wp-caption img {
      margin-bottom: 5px;
      padding: 0;
      border: 0 none;
      }

.wp-caption p.wp-caption-text {
      font-size: 11px;
      line-height: 17px;
      padding: 0 4px 5px;
      margin: 0;
      }

/* IMAGE POSITIONING
/* ----------------------------------------------*/

.aligncenter, div.aligncenter {
      display: block;
      margin-left: auto;
      margin-right: auto;
      }

.alignright {
      float: right;
      }

.alignleft {
      float: left;
      }

Credit goes to Isaiah for the solution.

To stay updated with the latest blogging tips, get the daily update into your inbox via email subscription. Happy blogging!

Related posts

Sponsor of The Month

{ 13 comments }

syuxx August 11, 2008 at 4:59 pm

the radius is different in other browser.
i think this also should be compiled along with javascript.
doesn’t it?

syuxx’s last blog post..Friendster Auto-Friend Adder & Comment Software

Jay August 11, 2008 at 5:15 pm

What’s up Yan? Yeah I don’t like the image caption feature at all. Although, it is much better if you style it to match your theme, etc.

Cheers!
Jay

Yan August 11, 2008 at 5:43 pm

@syuxx – You have your point. I’m not aware of using Javascript. To my knowledge, it only works if the browser supports it.

@Jay – Hey, hey, hey, I’m glad you drop by. Thanks for your suggestion, Jay. Why didn’t I think of that?

Ultimate Blogging Experiment August 12, 2008 at 7:33 am

Good tips for making image caption work with CSS. Since a lot of people do not know how to do this this will help in lot of bloggers do it by each of your steps.

Ultimate Blogging Experiment’s last blog post..Quality or Quantity of Blog Posts

Brad Blogging.com - Personal Blog Tips And Blog Help August 12, 2008 at 10:58 am

I didn’t bother adding a caption to my pictures. After the first caption wasn’t styled and appeared as regular text, I decided to just not add them anymore.

Thanks for the code though, I might just start using them :)

Brad Blogging.com – Personal Blog Tips And Blog Help’s last blog post..Conducting an Experiment – Advertising And Guest Posts

Nihar August 12, 2008 at 6:46 pm

I am using the image caption but should blend with the blog theme’s color

AZ Blogging August 12, 2008 at 11:25 pm

I envy you guys talking all these WP stuff. I was with wordpress but due to certain problems with hosting, I had to move to blogger. I am enjoying many benefits with blogger but i will be migrating back to wordpress at the end of the year.

I LOVE WORDPRESS.

AZ Blogging’s last blog post..Rambling – A journey to Niche-blogging

Yan August 12, 2008 at 11:31 pm

@Uncle Che – Hey, buddy. The fact is I haven’t heard of any host that is not compatible with WordPress. Which hosting provider are you talking about?

Yes, yes, yes…without a doubt, WordPress is more flexible than blogger in general.

jeflin August 13, 2008 at 10:01 am

I am no expert on CSS but this code is pretty useful for me, in case I wanted to use the image captions.

But for now, I find them to be a redundant feature.

Yan August 13, 2008 at 11:56 am

@jeflin – Yes, contrary to popular belief, I use less images here than any other blogs.

Shanker Bakshi August 13, 2008 at 1:01 pm

I use at least one image in my every post. But not very much enthusiatic to use Image captions.

Shanker Bakshi’s last blog post..Meet The Shanker Bakshi Junior

EmmaB September 1, 2008 at 12:47 pm

Thanks for sharing this tidbit. My captions looked missed up due to the theme being released before the feature was added

EmmaB’s last blog post..5 Blogging Platforms To Consider

mommyknows March 13, 2009 at 12:51 pm

I added the code to my style.css file and still ‘no’ captions. Is there something else I need to change.

I added a caption to the first image in this post: http://mommyknows.com/growing-wider-thanks-to-cupcake-pops/

I’ve looked and looked for a solution … any ideas?

Thank you!

mommyknows´s lastest post..Growing Wider Thanks to Cupcake Pops

{ 1 trackback }

Previous post:

Next post: