I\'d like to right-align block elements in a floating container.
Assume the following markup.
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/