WordPress 2.6 Floating Images within post

If you’ve not upgraded your blog to WordPress 2.6 yet, do it now, because it has got cool new features and WordPress 2.5.x wouldn’t be supported further. One among the many new features that WordPress 2.6, is the text editor let you float images within the post content so that the text wraps around the images properly. You can […]

If you’ve not upgraded your blog to WordPress 2.6 yet, do it now, because it has got cool new features and WordPress 2.5.x wouldn’t be supported further.

One among the many new features that WordPress 2.6, is the text editor let you float images within the post content so that the text wraps around the images properly. You can align the images to be “left”, “right” or “centered”. When you use the text editor to align the images, WordPress adds class=”alignleft”, class=”alignright” or class=”aligncentered” to the ‘img’ tags or its surrouding ‘div’ element, when you choose left, right or center alignment for your images.

The post looks aligned to the left, right or centered within the WordPress admin area, but when you see the post on your site, it may not look properly aligned. It is because the theme that you are using, may not be aware of those classes added by WordPress.

You can easily overcome this porblem by adding the following code to your style.css:

img.alignleft, div.alignleft {
float:left;
margin:0 0.5em 0.5em 0;
}
img.alignright, div.alignright {
float:right;
margin:0 0 0.5em 0.5em;
}
img.aligncentered, div.aligncentered {
text-align:center;
margin:0 auto;
}

Source:→ WP Layer