Replies: 2 comments 2 replies
-
Hi Ben! my strategy is: use gap as often as possible but don't feel bad if there are scenarios where margin are needed. my appreciation of gap: mostly about the shifting of spacing ownership and it's more flexible i18n spacing. |
Beta Was this translation helpful? Give feedback.
-
I can 100% see using The fact that <section class="prose">
<h2>...</h2>
<p> ... </p>
<p> ... </p>
</section> ... where I'd have styles like Anyway, I'm just thinking out loud. I thought maybe I was just missing something non-obvious; but, it sounds like we're all still just trying to do our best when it comes to managing margins. I feel like I remember you and Una talking about some new / proposed CSS property that specifically deals with margin collapsing at the edges of containers ... perhaps once that lands in browsers, it will solve all our problems :D |
Beta Was this translation helpful? Give feedback.
-
@argyleink I'm completely fascinated by your use of
flex
andgrid
to space content blocks (headers, paragraphs, blockquotes, etc). But, I'm having trouble reconciling the technique with theli
element. Since theli
has adisplay:list-item
, which has a special meaning (gives the element its marker), I can't just change the defaultdisplay
toflex
in order to allow for proper spacing of nested paragraphs:I could wrap the inner-content in a host element to apply the spacing:
Which works if I have complete control over the content. But, imagine that this context also has to contend with user-provided content. In that, perhaps the content being rendered is something like this GitHub Issue content. A user wouldn't know to wrap list item content in a spacer.
Which then leads me to thinking that if I have to render user-generated content in an app, I'm going to just have to rely on native margin collapsing and revert back to use of things like
:first-child
,:last-child
,:first-of-type
shenanigans to make sure margins work well in all kinds of scenarios. And, if that's the case, is going down theflex
/grid
based margin technique moot?To be clear, I understand that I can still use this technique in contexts that I totally control. But, the question is, if an application has to render user content, and I have to have a more natural / native way to control the margins within that user content, does it even make sense to mix-and-match more free-flowing content areas.
I've been going through your normalize.css, and when I see this block, I get the sense that you're also struggling with the same thing:
... which falls down a bit if you wrap your
dt
/dd
pairs in a wrapper (now allowed by the spec as far as I know):In this case, none of the
dt
get a margin because they are all:first-of-type
.Apologies for the long, rambling question - I'm sure that I haven't well articulated my question. Ultimately, I'm trying to understand how to best manage
margin
in a robust application; and, after 25-years in this business, I still feel like I'm trying to figure it out. And when I saw your use offlex
/grid
to space content, I thought that "the one weird trick"; but, then I remembered theli
and it all sort of unravelled.Just looking for some advice. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions