Kyle Shevlin 2/26/2024

No Outer <code>margin</code>

Read Original

This article discusses a common anti-pattern in front-end development: applying margin or padding to the outermost element of a reusable component. It explains how this breaks encapsulation, forces 'compensations' in other components, and incorrectly makes a component responsible for external spacing. The author provides code examples and advocates for components to only manage their internal layout.

No Outer <code>margin</code>

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser

Top of the Week