Post

Animating the gap would be nice. Say you have a flex-row container, where you can add elements that have their width animate (grow) on insert. When the element is added, it causes a shift due to the extra gap added. Having a way to grow that gap would keep the insert animation smooth.

Last thing: This expression `@scope (h3) to (p)` means "Inside an h3 but outside a p", not "the siblings between h3 and p". I think having the same keywords to mean different (but close) things can create a lot of confusion.

Yep, it technically doesn't work as I stated in the article. The proposed idea here is the “gap between the h3 and p”. Not sure yet on how to handle this the best.

Now that I'm thinking about it, it would be nice to have a selector for stuff between two siblings. That would not be easy to implement, though, based on the time we had to wait for :has…

If the top element has `gap-below: 10px` and the bottom el has `gap-above: 20px`, who wins? I like the margin semantics for that, but gaps act more like children of the container, not like margins, which act more like pseudoelements.

That's a very good point! I think we need a way to select two elements and customize the gap between them. The gap above thing will probably cause more confusion.

Happy to see this discussion. I usually add "spacer" components to customize gaps like that as my current workaround. A standardized approach would be nice.

innit it was one of those classics that took about 30 mins to write that exploded in popularity. A lesson there for us both at the moment 😅

Oh yes! I remember the same thing happened when I wrote about the CSS behind the new Facebook. I did it in one go in the morning and just hit publish! Good times.

I'd rather have a margin-collapse property that allows me to use regular margin properties, but have them collapse like in a regular block layout. Then, no negative margins are needed. Just apply margins as usual and set gap to 0.

I've been thinking in the same terms. Having to combine gap and margins feels a bit like an ugly hack. gap-before makes sense, but maybe something with -start and -end would be more consistent with other CSS props (margin-block-start etc)