DEV Community

Discussion on: Why I fell in love with margin-top

Collapse
 
dippas profile image
dippas • Edited

I use the exact opposite guideline for years in large (modular) projets, which is using margin-bottom/right and IMHO is way better,

Your examples of CSS for margin-top shouldn't be used, as it can cause a lot of issues in maintenance among others (eg: performance/speed),

Also your point #3 I really can't see the difference from you top VS bottom.

About the headaches, no headaches at all, just a matter on how to do things properly

Collapse
 
receter profile image
Andreas Riedmüller

I did use margin-bottom for some time and it has most of the advantages. Especially #1 (less code navigation) was what convinced me to switch.

You mean ~ *:not(br) right? You can also go with + br + * which is easier to understand.

Of course, with margin-bottom you don’t need the + cominator, but you will have a harder time if you have various preceding elements that need different spacing.

What are the advantages of margin-bottom that conviced you? Let me know!