If the styling for captions in WordPress 2.6 doesn’t seem to work…

I had some trouble getting the captions to look good in WordPress 2.6. Here’s how I solved it.

First, I added this code from the default theme to my style sheet:

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

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

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

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

That should have done the trick, but it didn’t. The problem was, the default CSS file has code for .alignright and .alignleft elsewhere, and mine doesn’t. So if the above code doesn’t work, what you need to add somewhere – anywhere in your CSS file – is:

.alignright {
float: right;
}

.alignleft {
float: left
}

That worked for me.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Don't miss an article!

 Subscribe in a reader or get every article delivered by email