I\'d like to right-align block elements in a floating container.
Assume the following markup.
Add overflow: hidden;
to the parent div of the images. It will wrap around the images when you float them, and clear the images from the right with clear: right
http://jsfiddle.net/zBnqQ/15/
The correct way to align an element with CSS is to set text-align on the container and margin on the children elements.
Your tries are wrong since you are setting margin and text-align on the img tag. Your css should look like:
div {
float:right;
text-align: right;
}
img {
margin: 0 0 0 auto;
}
Just tested on ie8, ff and chrome.
http://jsfiddle.net/notme/wfwjf/2/