Lobotomized Owls

Avatar of Chris Coyier
Chris Coyier on

I had a post in my drafts for CSS-Tricks recently I called “Removing the Space from the Bottom of Modules”. It’s all about that tricky situation where you want even padding all the way around some elements to visually separate them. But elements inside will also need bottom margins, and that might lead to extra space along the bottom where that margin hits the padding.

Apparently I’m getting old and losing my mind, because I’ve already written about it. But I didn’t come to any stunning conclusion in that article. The best I came up with was a kinda gross compound selector that I don’t even want to talk about.

Heydon Pickering does have a stunning conclusion for this issue:

* + * {
  margin-top: 1.5em;
}

I’d definitely try that in a new project. It does make me think that future CSS could help us here though. Perhaps specifying that a particular edge of padding was allowed to collapse into margin?

Direct Link →