by cousin_it · 6y ago · 0 comments
For example, it feels nice to define margin or padding on a <p> element, but what does that mean - distance between two paragraphs? Between paragraph and heading? Between paragraph and bulleted list? Using spacers seems like the only way out of this madness.
What’s befuddling to me about these threads is that they keep trying to make an absolute case. It’s true, I use margin less now that I have grid gap, but there’s still a place for it.
And protip: Whenever you have a CSS problem, think: "Oh, I'll just use negative margins!"
I don't want to be rude but you are completely misunderstanding what CSS and HTML are supposed to do.
1) The <p> tag denotes that the content in the element is a paragraph in the document.
2) The styling is just tell the client (which is typically a browser) how the element is supposed to be styled. It isn't supposed to mean anything in relation to other elements and it isn't supposed to convey meaning.
Generally wherever possible you should try to separate the markup and its styling. You can't always do that, but you should try to.
Can you explain what spacers are and why they'd be better for this example? Why not use CSS rules that say e.g. "use 1em spacing between p tags", "adding 2em spacing between h1 tags and p tags"?
p+p{margin-top:1em}
h1+p{margin-top:2em}
This says more or less directly "1em between p and p, 2em between h1 and p". The values can be changed independently, with no need for collapsing margins and so on. It's a bit unusual though.