Missing margin collapse

Usually in css margins on siblings collapse.
E.g.

<div style="margin-bottom: 16px;">ABC</div>
<div style="margin-top: 16px;">DEF</div>

Normally this would create a 16px gap between the two block elements, but in unity there is no margin collapse. So the gap is 32px.

I have not been able to find anything on this. Is it on purpose or?

This along with not having :not, :first-child and :last-child makes it more challenging. I might need to add elements just for spacing.

Hi! The USS styles don’t implement margin collapse. As far as I can tell, this is the first request for such feature. This is probably pretty common in web design, maybe a bit more unusual for gamedev.

That being said, introducing that feature would be a breaking change for existing project, so it would have to be opt-in.

What’s the usecases for this feature? Looks really confusing, honestly, not sure I would’ve wanted this behavior.

an opt-in way to collapse margins would be awesome to have!

One use-case would be to have a list of elements with the same spacing between them as they have to an outer element. I could just set one of the adjacent sides of siblings to 0 margin, but then if the direction or alignment ever needed to change, I’d have to edit this style again. If I wanted to change this in runtime, I’d have to change the style in runtime.

But maybe I’m missing something and there is already a dead simple (as in: collapsing margins) way to solve this? I currently can’t think of another way that doesn’t include more code or adding+managing more elements… is there another intended way to accomplish this?