{"id":1673,"date":"2024-04-11T15:12:32","date_gmt":"2024-04-11T21:12:32","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=1673"},"modified":"2024-04-11T15:12:33","modified_gmt":"2024-04-11T21:12:33","slug":"gap-is-the-new-margin","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/gap-is-the-new-margin\/","title":{"rendered":"Gap is the new Margin"},"content":{"rendered":"\n<p>In 2020, Max Stoiber wrote the \ud83c\udf36\ufe0f spicy <a href=\"https:\/\/mxstbr.com\/thoughts\/margin\/\">Margin considered harmful<\/a>. On one hand, it seems silly. The <code>margin<\/code> property of CSS is just a way to push other elements away. It&#8217;s very common and doesn&#8217;t feel particularly problematic. On the other hand&#8230; maybe it is? At least at the design system component level, because those components don&#8217;t know the context in which they will be used. Max wrote:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Margin breaks component encapsulation. A well-built component should not affect anything outside itself.<\/p>\n<\/blockquote>\n\n\n\n<p><a href=\"https:\/\/dev.to\/argyleink\/5-css-predictions-for-2020-pl3\">Adam Argyle wrote slightly earlier<\/a> that he predicted the usage of <code>margin<\/code> to naturally decline:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Prediction<\/strong>: margins in stylesheets will decline as gap in stylesheets climb<\/p>\n<\/blockquote>\n\n\n\n<p>Well it&#8217;s four years later now! Has any of this played out? Well it&#8217;s super hard to know. Anecdotally, it <em>feels<\/em> like <code>gap<\/code> is much more heavily used and my own usage is certainly up. <a href=\"https:\/\/chromestatus.com\/metrics\/css\/timeline\/popularity\/89\">There is public data on usage of CSS features<\/a>, and, amazingly, <code>margin<\/code> usage does appear to be slowly going down.<\/p>\n\n\n\n<!--more-->\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"469\" src=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM.png?resize=1024%2C469&#038;ssl=1\" alt=\"\" class=\"wp-image-1675\" style=\"width:668px;height:auto\" srcset=\"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM.png?resize=1024%2C469&amp;ssl=1 1024w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM.png?resize=300%2C137&amp;ssl=1 300w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM.png?resize=768%2C351&amp;ssl=1 768w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM.png?resize=1536%2C703&amp;ssl=1 1536w, https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/Screenshot-2024-04-11-at-1.26.09%E2%80%AFPM.png?w=1674&amp;ssl=1 1674w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><figcaption class=\"wp-element-caption\">Looks like a slow but sure declare the last 18 months or so.<\/figcaption><\/figure>\n\n\n\n<p>I say &#8220;amazingly&#8221; because the way this data is collected checks if the site uses the feature <em>at all<\/em>, not how <em>much<\/em> it&#8217;s used.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>The chart below shows the percentage of page loads (in Chrome) that use this feature at least once.<\/p>\n<\/blockquote>\n\n\n\n<p>So seeing a dip here means less sites are using the <code>margin<\/code> properly <em>entirely<\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In 2020, Max Stoiber wrote the \ud83c\udf36\ufe0f 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&#8217;s very common and doesn&#8217;t feel particularly problematic. On the other hand&#8230; maybe it is? At least at the design system component level, because [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1677,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[29],"tags":[7,153,152],"class_list":["post-1673","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-css","tag-gap","tag-margin"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2024\/04\/gap-thumb.jpg?fit=1000%2C500&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/1673","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/comments?post=1673"}],"version-history":[{"count":2,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/1673\/revisions"}],"predecessor-version":[{"id":1676,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/1673\/revisions\/1676"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/1677"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=1673"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=1673"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=1673"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}