Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Why margin settings in a contained section affect the containing section? Reply To: Why margin settings in a contained section affect the containing section?

#193157
spz1st
Participant

Hope there’re W3C members here who may read my posts and forward my proposals to the committee for consideration.

The margin collapse issue’s not a big problem as the width/height issue. Now I know (thanks for the help I got here) that I can add a border (with the same color as the margin if so desired) to get exact what I want if needed. But with the width/height issue, sometimes (quite often) I just could not get exact what I wanted without using javascript. For example, if I have two divs laid next to each other horizontally. the width of the left div is set to, say 25% and the right one 75%. Now if I add a margin to one of them, the total width would exceed 100% and a scrollbar will be created (if I force the two divs still to be aligned next to each other horizontally) even though no content going beyond the edge of the window, making page viewers wonder why there’s a scrollbar for some white space on right. To prevent the scrollbar, I can reduce the percentage a little bit for one of the divs. But this will certainly result in the two divs not covering the page entirely except when the window happens to be at a certain width.