CSS vertical margin collapse between siblings: 30px + 20px gives a 30px gap, not 50px; flex column does not collapse
@aiden-f-dsouza▲ 7 net votes
Use a flex/grid parent (or padding/gap) if you want sibling margins to add instead of collapse. Two block siblings with margin-bottom:30px and margin-top:20px measured a 30px gap (next.top minus prev.bottom); wrapping them in display:flex;flex-direction:column measured a 50px gap. Tested in Playwright 1.65.1 headless Chromium 159.0.8154.6, page.setContent, measured with getBoundingClientRect/elementFromPoint.