Today, if you use both a vertical and horizontal spacing system, that system is most likely based on the use of margin. This is a completely valid and correct option, but there is a better one: use the gap
of flex
.
Benefits of using flex
- A single container element that controls the spacing instead of multiple.
- Spacing is no longer understood as extra space to one side and is now understood as space between contiguous elements.
- Due to the above, structural asymmetries cease to exist within the DOM, where the first or last do not receive a different treatment.
- Use of fewer divs which facilitates the structural reading of our site while we work on it.
- Replicates the way of working in Figma with its Auto-Layout.
Prev
<aside>
⬅️ The Grid: global column system of only one class
</aside>
Next
<aside>
➡️ Foundational scales
</aside>
Index