Live data from Hacker News

Use spacer components instead of CSS margins (2020)

mxstbr.com

31–40 of 230 posts

Re: Use spacer components instead of CSS margins (2020)

#32
post #9

I think the main bugbear of margins that the article doesn't mention is margin collapse: I personally don't find the rules super intuitive and I would rather just be explicit with spacing than have the browser collapse things together!

One way around this is to only define margins at the end of the container.

Re: Use spacer components instead of CSS margins (2020)

#36
post #33

Quoted post unavailable.

The text of the article contains an argument to avoid margins when creating reusable components, instead allowing the consumer of the component define its margins. There is no argument made against using margin properties.

Re: Use spacer components instead of CSS margins (2020)

#38
post #33

Quoted post unavailable.

The text of the article contains an argument to avoid margins when creating reusable components, instead allowing the consumer of the component define its margins. There is no argument made against using margin properties.

Then the title of the article is misleading and should be changed to avoid confusion

Re: Use spacer components instead of CSS margins (2020)

#40
post #38

Earlier quoted context omitted.

The text of the article contains an argument to avoid margins when creating reusable components, instead allowing the consumer of the component define its margins. There is no argument made against using margin properties.

Then the title of the article is misleading and should be changed to avoid confusion

or you could maybe read the article before looking at its source code for a gotcha?
Post reply on HN