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.
Share and contribute or get technical support and help at My Digital Life Forums.
Related Articles
- Caption Disabler WordPress Plugin to Disable and Remove Captions Functionality
- Switch and Change Back to Office 2003 Default Font and Style Set in Office Word 2007
- Meaning of TVAnts Buffer Progress Bar Colors
- How to Disable Image and Video Captions Feature and Auto Adding of Shortcode in WordPress 2.6
- WordPress 2.6 with Change Revision Tracking Feature Available for Free Download
- How to Change the Frequency or Interval WordPress Auto Saves An Editing Post or Page
- Website Loading Time and Speed Checker
- Permanently Disable AdSense-Deluxe WordPress Plugin Reward Plugin Author Option
- Remove Microsoft Word Manual Formatting or Copied Formatting from External Source
- Download WordPress 2.3 Release Candidate 1 (RC1) with Tags Support

































July 20th, 2008 10:05
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.
September 16th, 2008 01:05
Thank you so much for sharing this code! I was going nuts trying to figure out how to fix my captions!