DEV Community

Discussion on: Don’t Use Margins For Spacing Between Components, Use Gaps

Collapse
 
talr98 profile image
Tal Rofe

Grid gap is great when your have a website that would support both "LTR" and "RTL" directions. For example if you'd use margins only, margin-left may become foolish in RTL, but useful in LTR.

So you definitely should be using Grid gap as a replacement for margins.
The actual good use for margins is only vertical margin.

Anyway, if you have a website you know for sure would only support one direction, either "LTR" or "RTL", you can use margins instead of Grid.
You just need to prevent the last element in a row to have an ignorant margin by using the selector ":not(:last-child)".

Collapse
 
dippas profile image
dippas • Edited

For those bi directional sites you can use CSS Logical Properties in that case for margin-left it would be margin-inline-start