I always thought that the basic theory behind CSS fields was very simple. A div with a 10px edge will create a 10px cushion around this element. When two divs are placed side by side, both with a 10px edge, this results in divs being 20px; both elements have a 10px margin, which results in a 20px distance between the elements. It seems right, and I always thought it was a fact.
HOWEVER, I recently discovered that if instead of two divs located side by side and placing one below the other, the border between these two elements now is only 10 pixels. What happened to the 10px mark issued by another div? Why is there no consistency between side by side and vertically stacked?
The indentation essentially says "don't put anything in x pixels of me." Under anything, does this include the fields of other elements? In the case of side by side the answer seems yes, the margin says: "Do not put anything, including your own margin, in x pixels of me." In the vertical direction, apparently this is the last?
Please, someone can clarify, so I can put him to bed and continue my evening :)
source
share