{"id":5819,"date":"2025-05-08T13:06:48","date_gmt":"2025-05-08T18:06:48","guid":{"rendered":"https:\/\/frontendmasters.com\/blog\/?p=5819"},"modified":"2025-05-08T13:06:48","modified_gmt":"2025-05-08T18:06:48","slug":"easier-layout-with-margin-trim","status":"publish","type":"post","link":"https:\/\/frontendmasters.com\/blog\/easier-layout-with-margin-trim\/","title":{"rendered":"Easier layout with margin-trim"},"content":{"rendered":"\n<p>Without <a href=\"https:\/\/webkit.org\/blog\/16854\/margin-trim\/\">the new property <code>margin-trim<\/code><\/a>, I&#8217;m forever doing <code>:last-child { margin-block-end: 0; }<\/code> and things like that to prevent an elements margin from <em>combining with a parent elements padding to make <strong>too much<\/strong> space.<\/em> The fact that we can avoid the extra awkward targeting and removal rule with this is great. I&#8217;ll stick by Coyier&#8217;s Padding Law:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>When you add <code>padding<\/code> to a container element, add <code>margin-trim<\/code> in the same directions.<\/p>\n<\/blockquote>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Without the new property margin-trim, I&#8217;m forever doing :last-child { margin-block-end: 0; } and things like that to prevent an elements margin from combining with a parent elements padding to make too much space. The fact that we can avoid the extra awkward targeting and removal rule with this is great. I&#8217;ll stick by Coyier&#8217;s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5820,"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,152],"class_list":["post-5819","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-the-beat","tag-css","tag-margin"],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/frontendmasters.com\/blog\/wp-content\/uploads\/2025\/05\/margin-trim-simple-scaled-1.png?fit=2560%2C1439&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/5819","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=5819"}],"version-history":[{"count":1,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/5819\/revisions"}],"predecessor-version":[{"id":5821,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/posts\/5819\/revisions\/5821"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media\/5820"}],"wp:attachment":[{"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/media?parent=5819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/categories?post=5819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/frontendmasters.com\/blog\/wp-json\/wp\/v2\/tags?post=5819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}