Giter Site home page Giter Site logo

Comments (6)

fantasai avatar fantasai commented on August 16, 2024 3

That note is about the top and bottom margins of a single box, not about margin collapsing in general! I love that CSS has margin collapsing, for exactly the reason @scottkellum describes. But the rules that allow a given element's own top and bottom margin to collapse, essentially through the element itself, are super weird and create a lot of confusion and complexity.

from cssremedy.

scottkellum avatar scottkellum commented on August 16, 2024 2

While I understand the annoyance of margin collapsing I have shifted my thinking on them. Margins are a way of saying the thing above/below me should be no less than this far away. This is super useful if you have a heading and paragraph where the heading requires more space. The heading space takes precedence and the paragraph margin collapses resulting in a clean and predictable space below that heading. If padding were used and the values were different between multiple smaller elements, then the space below the heading would be inconsistent.

That said, well managed padding and removed margins can be implemented well and I understand the appeal of that control.

from cssremedy.

jensimmons avatar jensimmons commented on August 16, 2024 1

I'm leaning towards not doing this — not removing top margins on everything to effectively get rid of margin collapsing. It seems like too drastic of a "recommendation" to be making for every website to do. Too far from the CSSWG's decisions.

from cssremedy.

jensimmons avatar jensimmons commented on August 16, 2024

This issue has been open for a while now, without much new debate. I'm going to close it as fixed. Let's not remove the top margins of anything. (Let's deviate from Bootstrap.) It's too opinionated.

from cssremedy.

stevenadams avatar stevenadams commented on August 16, 2024

I know this is closed but I thought I'd weigh in with something that we noticed in a GovUK project - that margin collapsing didn't happen on Firefox but did on Chrome. So you got different layouts in two modern browsers. I also like only margin bottom as there is one direction for spacing.

from cssremedy.

frivoal avatar frivoal commented on August 16, 2024

@stevenadams, As far as I know, the csswg believes margin collapsing to be precisely defined and interoperably implemented nowadays. If you've found a case where browsers differ, I encourage you to report it at https://github.com/w3c/csswg-drafts/issues

from cssremedy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.