News for hackers. Stuff that matters.
Re:They Say: Do Not Use Margins in CSS. How I Use Them Anyway by atoav on Saturday January 15, 2022 @03:54AM (#29944932)
Short question: Why not select the button element in this case — if you already want to select all of them anyways?

    button {
        margin: 1em;
    }
or if you just want certain buttons

    .someparent button {
        margin: 1em;
    }
I tend to use classes only to specify the identity of a thing: so something like .close-button or similar.
Re:They Say: Do Not Use Margins in CSS. How I Use Them Anyway by montroser on Saturday January 15, 2022 @07:33AM (#29945874)
In a smaller project, styling all buttons might be a fine/good way to do it. But in a larger project, it is inevitable that you will have buttons which you actually don't want to inherit your global styles, and it's a pain and messy to have to override/undo the styles. Like, you bring in a third-party video player, or checkout form, or chat client, and it's busted because your global margin button styles are leaking in.

As to why not scope with .someparent, it can work, but if you already have spacing utility classes ready to go, it's easier to just add the three characters in the class. And as a bonus, when you add another button somewhere else nested way deep under .someparent, it won't accidentally inherit the margin you meant for the first button.