0

Gap is the new Margin

 4 weeks ago
source link: https://frontendmasters.com/blog/gap-is-the-new-margin/?ref=sidebar
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
gap-thumb.jpg?fit=1000%2C500&ssl=1

Gap is the new Margin

April 11, 2024

In 2020, Max Stoiber wrote the 🌶️ spicy Margin considered harmful. On one hand, it seems silly. The margin property of CSS is just a way to push other elements away. It’s very common and doesn’t feel particularly problematic. On the other hand… maybe it is? At least at the design system component level, because those components don’t know the context in which they will be used. Max wrote:

Margin breaks component encapsulation. A well-built component should not affect anything outside itself.

Adam Argyle wrote slightly earlier that he predicted the usage of margin to naturally decline:

Prediction: margins in stylesheets will decline as gap in stylesheets climb

Well it’s four years later now! Has any of this played out? Well it’s super hard to know. Anecdotally, it feels like gap is much more heavily used and my own usage is certainly up. There is public data on usage of CSS features, and, amazingly, margin usage does appear to be slowly going down.

Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM-1024x469.png?resize=1024%2C469&ssl=1
Looks like a slow but sure declare the last 18 months or so.

I say “amazingly” because the way this data is collected checks if the site uses the feature at all, not how much it’s used.

The chart below shows the percentage of page loads (in Chrome) that use this feature at least once.

So seeing a dip here means less sites are using the margin properly entirely.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK