Comments (6)
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.
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.
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.
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.
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.
@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)
- Twitter/social media accounts HOT 1
- vertical-align and alt text HOT 1
- Text Underline position for CJK lang
- height 100% or 100vh on body & html? HOT 11
- Cater for "hidden" attribute HOT 1
- Path to v1.0? HOT 2
- Audio tag without controls should not be `display:block` HOT 1
- `display:block` negates `vertical-align` HOT 6
- `article, etc. {display:block;}` is not enough for oldIE HOT 6
- white-space:pre-wrap vs. overflow:auto for `pre` HOT 2
- Relation to normalize/sanitize.css HOT 1
- Image causes unexpected if used inside intrinsic parent
- svg display attribute ignored HOT 2
- `inert` attribute remedy? HOT 1
- CSS Remedy without specificity HOT 8
- Suggestion: Body centering (with code suggestion) HOT 4
- Opt out of `monospace` font-size quirk
- Preflight img {display: block}
- Is this project dead? HOT 1
- Is this ready for production? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cssremedy.