TheMovieman Posted November 11, 2009 Share Posted November 11, 2009 I noticed that in my current theme, when I have a caption associated with an image, it will not center, it'll stay to the left but when I remove the caption, it centers as planned. Anyone run into this? Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted November 12, 2009 Author Share Posted November 12, 2009 Well, discovered it's a bug within Wordpress. The solution is to add the <center></center> tags around the image portion of the html. Quote Link to comment Share on other sites More sharing options...
Bob Crabb Posted November 14, 2009 Share Posted November 14, 2009 (edited) The center tag was deprecated in HTML 4.01 and is not supported in XHTML. In my opinion, it should be forgotten and never used. There are several W3C compliant ways of centering your images and captions. One would be to edit the CSS for the parent element. For example, in a page on your site that I viewed, the image that you centered is in a div class="textwidget". If you can find the CSS declarations for that class, you can add a line >text-align: center; That could create problems, however, if there are other cases where this class is used that you do not want centered. Therefore it would probably be best to add a class in your CSS file like this: > .center_txt { text-align: center; } then, in the html for the images that you want centered add center_txt to the class attribute of the parent element. Therefore, <div class="textwidget"> would become <div class="textwidget center_txt"> You could also add an inline style attribute, but if you are going to apply it in several places, it is easier to just add a class to the stylesheet. Edited November 14, 2009 by Bob Crabb Quote Link to comment Share on other sites More sharing options...
Bob Crabb Posted November 14, 2009 Share Posted November 14, 2009 After posting that, I realized that you might not want everything in the box centered. For example if you want the captions to be left justified, but the image centered, then you would wrap the img tag (and anchor if it is linked) in a div with either inline style or class that would center, as described in my previous post. Quote Link to comment Share on other sites More sharing options...
TheMovieman Posted November 15, 2009 Author Share Posted November 15, 2009 (edited) I've decided to forgo the center image with the caption, it's nice to have but not necessary. Edited November 15, 2009 by TheMovieman Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.