How to Change the CSS Style, Font, Spacing, Alignment and Color of WordPress Image Captions

Since WordPress version 2.6, WordPress has added a built-in shortcode, “Caption”, which will be automatically rendered and translated into standard HTML CSS code to display the caption for the photo or image, which saved via media uploader, beneath it.

However, when WordPress appends the DIV styles to print the caption title under the picture or image, WordPress makes use of default alignment, color, font, spacing, and other styling attributes to display the image captions.

The default CSS styles for image with the caption may potentially breaks the blog or web page layout, does not validate against W3C xHTML standard, appears too closely with the text with no spacing in the post or page, or does not align as author’s wish.

For blogger who wants to modify the CSS styles of the caption that shows the image captions on screen after parsing the shortcode, add the following CSS code into the active theme’s style.css file:

/* 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 */

Above HTML CSS declaration is taken from WordPress 2.6 default theme. These newly added CSS styles are used to control and assign the appearance of the caption for the image posted on blog. Modify the code above in “style.css” file according to your own preference to have your own design and look.

3 Responses to “How to Change the CSS Style, Font, Spacing, Alignment and Color of WordPress Image Captions”

  1. Browsergames Fan
    October 27th, 2008 18:05
    3

    Wow, klasse für den CSS-Tipp. Habe den gleiche mal eingebaut und finde die Formatierung einfach klasse. Sieht optisch sehr ansprechend aus.

    Danke und gruss

  2. Gray
    September 16th, 2008 01:05
    2

    Thank you so much for sharing this code! I was going nuts trying to figure out how to fix my captions!

  3. Mark LaFlamme
    July 20th, 2008 10:05
    1

    For the life of me, I cannot get captions to work. It looks great in preview, but live, all the code spills out around the photo and there’s no caption at all. I added the caption code to my theme’s style.css but there was no change. Seems like I’m just one minor step away from making this work. If anyone has any ideas, I’d love to hear them. I’ll add a caption to my first post to demonstrate.

Leave a Reply

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>

Subscribe to comments feature has been disabled. To receive notification of latest comments posted, subscribe to My Digital Life Comments RSS feed or register to receive new comments in daily email digest.

New Articles

Incoming Search Terms for the Article

css font align - wp-caption css - css color change - css font alignment - liquid story binder software coupon code - how to change font and alignment on picture comments - wordpress change font color - adsense font - css font margin - change css color - caption font color style.css - change paragraph spacing in wordpress - css post image alignment for blogger - style font space - how to change life in css - change styles of wordpress posts - liquid story binder changing font colour - style wp-caption - change font spacing - Counter strike source color name change - css color chage script - decrease spacing in wp - font text style align - how to change font style - how to change css page color - style.css color change - wordpress caption code and css - css change alignment - css file color changer - how to change font in wordpress - style "font-align" middle - tomtom text color change how to - wordpress css code font color - wordpress color change - WORDPRESS + post styles for authors - change font color css default theme wordpress - change font spacing style.css wordpress - css font-spacing - css code for alignment - replace font colour tagline wp - setting font color in google chrome theme - wordpress css font color - changed paragraph spacing in wordpress - change style of wordpress code block - font color in css file code - how to change the fonts in a wordpress theme - how to change font colour blogspot - who to do the font color for a css file - align number css - change wordpress css -