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. Said another way, the need for adding margins between everything and trying to control it that way ceases to exist.
- 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.
Remove this Note
I need to add more video examples of this relatively new example
https://www.youtube.com/watch?v=VvqyUUROmJw
Index
Prev
<aside>
⬅️ The Grid: global column system of only one class
</aside>
Next
<aside>
➡️ Foundational scales
</aside>