I believe your chosen answer will not work:
http://jsfiddle.net/cNsXh/
change
Sorry, the above example was not correct. Now this. / change
As you can see, div #b will move under div #a because margin-left (or padding-left ) will be added at 30% . And since we are mixing percentages with pixel values ββhere, we cannot determine the values ββthat guarantee that they will always be exactly 100%.
You will need to use a wrapper for div #b , which will have a width of 30% , and not define the width for div #b , but define margin-left . Since the div is a block element, it automatically fills the remaining space inside the div wrapper:
http://jsfiddle.net/k7LRz/
This way, you will bypass CSS <3, which, oddly enough, has been defined in such a way that determining the size (width / height) will NOT subtract the margins and / or spacers and / or the width of the border.
I believe the CSS 3 field model will provide more flexible options. But admittedly, I'm still not sure about cross-browser support for these new features.
source share