HTML & CSS
To the green header div, and now you can see that it exceeds its fixed width designation of 960px. Surely padding shouldn't push out the fixed width? What is the correct way to pad instead?
padding and margin are added to the overall width. To avoid having to change with width setting every time you adjust padding/margin, it's easier to have an inner div on which you place the padding/margin. You just don't set a width on that inner div, in which case it just absorbs the padding/margin.
Really, though, in a situation like the one on that page, it never looks very good (to me, at lest) to have a background color on that content div. So it's a problem you can do without. (And I presume pink on green is for testing porpoises only? Surely? ...)
Thanks ... and yes the colours are just for testing purposes.
Or you can use css3 box-sizing: border-box;. The width then will not exceed what you stated
This topic is now closed. New replies are no longer allowed.