Needs (2020) in the title. Original discussion, 123 comments: https://news.ycombinator.com/item?id=22676442 Anyway, considered harmful articles considered harmful . There is a time and place for margins. Being thoughtful with them is a better approach than "banning margin from all components." Should I really ban the use of `margin-left: auto` when positioning my flexed elements? I don't think this article is actuall…
Out of curiosity, why do you need to use "margin-left: auto" when working with flexbox items? What is it that you're trying to do, which can't be solved with "justify-content" and "align-items"?
Use spacer components instead of CSS margins (2020)
91–100 of 230 posts
Re: Use spacer components instead of CSS margins (2020)
#92If you don't like thinking about them, sure .. introduce the concept of spacer elements in your framework. But outlawing something because you don't fully understand its purpose isn't the way to go.
Re: Use spacer components instead of CSS margins (2020)
#93I do agree generally, but it's funny that the suggested solution (spacers) are basically back to the old 1px transparent gif trick from the 90s/early 00s. Nothing wrong with the suggestion, but it's just ironic that we seem to be coming full circle again. Next we'll probably have posts extolling components for layouts ;)
They aren't the same thing. Check the link in the article [1]. It is using regular CSS, and some of those components use more modern things like Grids.
They also aren't applied between components like old element-spacers. Component Spacers have much more in common with regular margin/padding than with 90s spacers.
[1] https://seek-oss.github.io/braid-design-system/components/St...
Re: Use spacer components instead of CSS margins (2020)
#94I do agree generally, but it's funny that the suggested solution (spacers) are basically back to the old 1px transparent gif trick from the 90s/early 00s. Nothing wrong with the suggestion, but it's just ironic that we seem to be coming full circle again. Next we'll probably have posts extolling components for layouts ;)
Re: Use spacer components instead of CSS margins (2020)
#95Earlier quoted context omitted.
Or people could just read the very short article instead of instantly assume stuff based on the title here.
The article's own title is "Margin considered harmful" and the body finishes with the sentence "Ban margin."
Re: Use spacer components instead of CSS margins (2020)
#96mmm, spacer elements. the new 1999 is looking pretty awesome.
Re: Use spacer components instead of CSS margins (2020)
#97Margins are part of the specification of CSS. Banning them would be crazy. If you don't like thinking about them, sure .. introduce the concept of spacer elements in your framework. But outlawing something because you don't fully understand its purpose isn't the way to go.
Re: Use spacer components instead of CSS margins (2020)
#98Margins are part of the specification of CSS. Banning them would be crazy. If you don't like thinking about them, sure .. introduce the concept of spacer elements in your framework. But outlawing something because you don't fully understand its purpose isn't the way to go.
How did you arrive at the conclusion that OP doesn't understand margins?
Re: Use spacer components instead of CSS margins (2020)
#99Earlier quoted context omitted.
I did read the article and frankly it’s little better than the HN title. It’s heavily biased, fails to offer a convincing argument to anyone other than those who already believed the title, and even explicitly says margins should be banned. Simply put, it’s not a good article.
> It’s heavily biased What does "heavily biased" mean in this context? It's a straightforward article that puts forward a position, a series of propositions supporting that position, and a potential solution. It's biased in that the author has an opinion he's trying to convince people of by providing arguments in its favour, but that's what writing tends to do (including your comment). The "banning" stuff is obvious…
Any article stating something should be “banned” can’t really be described as a balanced discussion about the usage of that thing.
I’m all for discussions on why usage of something is bad but in the case of margins there’s clearly use cases that are suited to it, which other commenters have highlighted but which the article entirely glossed over.
So the article is more than just written as a persuasive piece; it misses any balance or contextual clarity and thus ends up dishing out bad advice as a result. Bad advice that is so strongly emphasised that lesser experienced developers would easily be intimidated by it.
Now if people want to discuss the strengths and weaknesses of margins and put forward alternative solutions in the process, that at least informs lesser experienced developers about ways to solve their real world problems rather than berating them for not following some misguided idealised view of perfection.
(Yes I know there was some details about alternative ways to implement a margin, but they were crap and lacked any detail, since the article was essentially a rant piece rather than technical document)
Re: Use spacer components instead of CSS margins (2020)
#100Earlier quoted context omitted.
My gotcha and the negative reaction to it shows only that the majority of readers are ok w/ using of clickbait titles. That's a pity. Although bringing attention to such things always gets negative reaction in the beginning. Not the reason to stay silent anyway. > If a clickbait title will lead to higher engagement, why would an author not use it? Out of intellectual/professional honesty e.g.?
The negative reactions to your post are due to the laziness of not reading the article and the "gotcha". I think most of us come to Hacker News for interesting discussions, and the torrent of confidently incorrect "this person is wrong" comments is not adding anything to any discussion. The top comment is already clarifying the title, so any other comment should be unnecessary, especially snarky ones. The gotcha is a…