-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try: Reduced specificity base block margins. #22051
Conversation
Size Change: -16 B (0%) Total Size: 825 kB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a step in a good direction. I would love if this rule could be removed entirely though. What blocks us to do that?
Yes this rule need eventually be removed entirely. A lot of core blocks rely on and assume the presence of these margins. These blocks need to be able to work without them, or we need something else to take it's place. For example anything wrapped in a figure element could probably work without them, but anything just in a div either need some margins in style.scss or theme.scss. We also need to handle the vanilla styles; what you see in the editor when your theme doesn't style it. There needs to be some margin rhythm for that. Some blocks compensate for these margins, i.e. with negative margins. Those need to me refactored. And finally, all the above needs good testing with themes and plugins, so that the breakage is acceptable. We should totally do it, but there are a few steps to get there. I wonder if a global style block margin has value? Probably not but something to think about. Thanks for the review! |
This is a simple change that benefits themes. It reduces the specificity of the rule that provides a baseline block margin. The baseline block margin is the margin above and below every block, which these blocks are born with. In master, this rule is so specific that it overrides many editor styles that should work.
0f3a384
to
99ec348
Compare
Tested this again with a couple of themes, and block nesting, and there appears to be no side effects that I an discern. Rebased and marging when the checks pass. |
I created #22208 as a place to start the discussion of removing the baseline margin entirely. |
This is a simple change that benefits themes. It reduces the specificity of the rule that provides a baseline block margin.
The baseline block margin is the margin above and below every block, which these blocks are born with.
In master, this rule is so specific that it overrides many editor styles that should work.
Before:
After:
Note how this theme provides 1em margins through the following editor style:
This overrides the baseline rule, as it should:
It also seems to work fine for TwentyTwenty and TwentyNineteen: