I am currently working on enhancing the visual appearance of a Bootstrap 4 card and encountered an issue:
https://i.stack.imgur.com/p8Qzhm.png
The spacing between the About the gig heading and the top Date item appears to be uneven. I would like to make this spacing consistent. Upon further inspection, I noticed that margins do not collapse as expected.
This is evident in the h3
element with About the gig, which has a bottom margin of 16px
:
https://i.stack.imgur.com/BIMHY.png
In contrast, the following element with the Date has a top margin of 24px
:
https://i.stack.imgur.com/ULQes.png
The total spacing between the About the gig and Date elements calculates to be 24px + 16px = 40px
, whereas margin collapsing should result in max(16px, 24px) = 24px
.
According to the explanation on https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Mastering_margin_collapsing, margin collapsing occurs for "adjacent siblings." The provided examples feature elements of the same type (e.g., two p
elements). Do elements need to be of the same type to be considered "adjacent siblings"? What could be causing the lack of margin collapsing in this specific scenario?