2 ms·
It feels like the author has read a lot of very sound arguments against using margins in component systems (they leak, they collapse, etc) and has taken those a
by onion2k 6y ago
It feels like the author has read a lot of very sound arguments against using margins in component systems (they leak, they collapse, etc) and has taken those arguments to mean "never use margins". I don't see a good reason to avoid margins in the specific "icon and label" example.
- Griffinsauce 6y agoIt's a bit contrived but say both the icon and the text element are components. Now you need to find a solution. I like to let the parent layout its children in a situation like that but that's also not without its issues.
- onion2k 6y agoIt's a bit contrived but say both the icon and the text element are components. Now you need to find a solution. There are solid arguments not to use margins with components, but that's not what the article is about. In the example in the article using margin is fine.
- krsdcbl 6y agoSpecially as margin collapse is a thing that only affects vertical margins on blocks. The "icon has margin right if something comes after it" is perfectly solveable with even CSS 2.1