You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
6.6 - Paragraphs with has-background have their automatic background overridden by global styles block padding #63164
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] BugAn existing feature does not function as intended
I discussed this problem with @talldan, @ramonjd, @tellthemachines, and @andrewserong before this issue was created. The description captures the dilemma in a nutshell. Unfortunately, at this stage, I don't have any solutions to it 😢
The general direction and thinking to date has been that global styles should override block library styles. This is the case in WP6.6 currently and has been in Gutenberg for a few releases now.
In 6.4 & 6.5, the automatic padding applied to blocks when they have a background (.has-background) overrides global styles padding rules for blocks.
In my view, this is a bug. It also requires theme authors to bump their own styles' specificity higher again to overcome it.
In 6.6, it's the other way around, global styles overrides the .has-background class due to a reduction in specificity.
IIRC the global styles referred to here are both any explicitly assigned to the block type and global padding.
If it is padding explicitly assigned to a block type in global styles, it probably should override the arbitrary default applied by .has-background. I'm a little less sure about global padding, I'd defer that one to the layout support experts.
What is a real problem here, is a possible change in padding for existing sites where their theme relies on the core .has-padding values. If they redefined their own padding values using a higher specificity, it could be less of an issue. The potential remains of course.
I'm not sure what the correct behavior is, possibly what 6.6 does makes the most sense.
The current behaviour in 6.6 makes the most sense to me also. I'm not sure how we can mitigate the downside though other than communicating it.
I'm also not sure that it's possible to go back to how it worked in 6.5 without bumping specificity, which might cause other issues.
Bumping the specificity of .has-background classes again will restore the bug preventing users from customizing padding on these blocks through global styles. That might be the direction we ultimately choose, I don't know. Personally, I don't feel there are any great options here.
Any bump in specificity may negatively impact the extended block style variations and the section styles feature which relies on uniform specificity so sections can be nested within each other e.g. creating pricing tables within a parent section.
Prior to 6.6, variation padding styles in global styles would override the .has-background classes due to style load order and matching specificity. If we restore the .has-background specificity to pre-6.6 levels, without changing block style variations too, we'll break those. Bumping the specificity of block style variations will have further ramifications that I'd need some time to unravel.
I'd love to hear others' thoughts on the best path forward from here.
If it is padding explicitly assigned to a block type in global styles, it probably should override the arbitrary default applied by .has-background.
In my opinion this is how it should work. WordPress should honor the theme's choice over its own opinionated styles. Allowing theme devs to style globally is a strong argument.
However, backwards compatibility in this case appears difficult.
I can't think of any deprecation/CSS/block parsing trickery that would circumvent the direct conflict, which means that there could be one 😄
The has-background rule has, however been around since at least 2017 - I can't find a reason for it other than it's what the old cover-text block had when it was merged with paragraph. I suspect because it made text look prettier.
Is there a case for deprecation? How would that look? Maybe it's worth advertising it in the Make Core blog and other channels - more ideas might surface.
For this, I lean slightly toward the idea that global styles not overriding the paragraph block's .has-background rules was a bug all along, and the behaviour in 6.6 addresses that for consistency. Otherwise there isn't a way for themes to uniformly override paragraph padding.
Since there's a question of what should happen for WP 6.6, I'll just ping @ellatrix for visibility, as it sounds like a decision needs to be made on whether to stick with the current behaviour in trunk?
Whichever way this ends up, please update the heading block's has-background rules to be consistent. That rule has been there for four years, applying padding to headings-with-backgrounds at a specificity of 0-1-1
Whichever way this ends up, please update the heading block's has-background rules to be consistent. That rule has been there for four years, applying padding to headings-with-backgrounds at a specificity of 0-1-1
Thanks everyone for the detailed discussion here. The 6.6 behaviour, Global Styles block padding overriding the automatic .has-background padding, was intentional and is being kept per the consensus above. But the specific downside raised, that themes had no way to override or remove the default background padding, has been addressed in WordPress/gutenberg#82024, merged to trunk. It routes the padding through a new --wp--style--block-background-padding custom property (see packages/base-styles/_variables.scss), with the old values kept as a fallback so existing sites are unaffected. This also unifies Paragraph and Heading on the same mechanism. For that reason, closing this one as fixed!
Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Type] BugAn existing feature does not function as intended
Activity
t-hamano commentedon Jul 5, 2024
Looking at this code, are the changes in WP6.6 intentional?
gutenberg/packages/block-library/src/paragraph/style.scss
Lines 41 to 44 in 2c5f768
cc @aaronrobertshaw
aaronrobertshaw commentedon Jul 5, 2024
Thanks for the ping @t-hamano 👍
I discussed this problem with @talldan, @ramonjd, @tellthemachines, and @andrewserong before this issue was created. The description captures the dilemma in a nutshell. Unfortunately, at this stage, I don't have any solutions to it 😢
The general direction and thinking to date has been that global styles should override block library styles. This is the case in WP6.6 currently and has been in Gutenberg for a few releases now.
In my view, this is a bug. It also requires theme authors to bump their own styles' specificity higher again to overcome it.
IIRC the global styles referred to here are both any explicitly assigned to the block type and global padding.
If it is padding explicitly assigned to a block type in global styles, it probably should override the arbitrary default applied by
.has-background. I'm a little less sure about global padding, I'd defer that one to the layout support experts.What is a real problem here, is a possible change in padding for existing sites where their theme relies on the core
.has-paddingvalues. If they redefined their own padding values using a higher specificity, it could be less of an issue. The potential remains of course.The current behaviour in 6.6 makes the most sense to me also. I'm not sure how we can mitigate the downside though other than communicating it.
Bumping the specificity of
.has-backgroundclasses again will restore the bug preventing users from customizing padding on these blocks through global styles. That might be the direction we ultimately choose, I don't know. Personally, I don't feel there are any great options here.Any bump in specificity may negatively impact the extended block style variations and the section styles feature which relies on uniform specificity so sections can be nested within each other e.g. creating pricing tables within a parent section.
Prior to 6.6, variation padding styles in global styles would override the
.has-backgroundclasses due to style load order and matching specificity. If we restore the.has-backgroundspecificity to pre-6.6 levels, without changing block style variations too, we'll break those. Bumping the specificity of block style variations will have further ramifications that I'd need some time to unravel.I'd love to hear others' thoughts on the best path forward from here.
ramonjd commentedon Jul 7, 2024
In my opinion this is how it should work. WordPress should honor the theme's choice over its own opinionated styles. Allowing theme devs to style globally is a strong argument.
However, backwards compatibility in this case appears difficult.
I can't think of any deprecation/CSS/block parsing trickery that would circumvent the direct conflict, which means that there could be one 😄
The
has-backgroundrule has, however been around since at least 2017 - I can't find a reason for it other than it's what the oldcover-textblock had when it was merged with paragraph. I suspect because it made text look prettier.ac911ae#diff-e13c67a8237605dbed9b6b676c56f4f9a7c75fe9c4117f623400ee09f5bd6a9fR17
Is there a case for deprecation? How would that look? Maybe it's worth advertising it in the Make Core blog and other channels - more ideas might surface.
Sorry, I know that's not very helpful.
andrewserong commentedon Jul 8, 2024
This is a tough one, good discussion, folks!
For this, I lean slightly toward the idea that global styles not overriding the paragraph block's
.has-backgroundrules was a bug all along, and the behaviour in 6.6 addresses that for consistency. Otherwise there isn't a way for themes to uniformly override paragraph padding.Since there's a question of what should happen for WP 6.6, I'll just ping @ellatrix for visibility, as it sounds like a decision needs to be made on whether to stick with the current behaviour in
trunk?joemaller commentedon Aug 13, 2024
Whichever way this ends up, please update the heading block's
has-backgroundrules to be consistent. That rule has been there for four years, applying padding to headings-with-backgrounds at a specificity of0-1-1gutenberg/packages/block-library/src/heading/style.scss
Lines 1 to 14 in 5dae25b
djcowan commentedon Jun 13, 2025
@joemaller
Did you ever find a working solution to the heading specificity issue mentioned that worked with theme.json and the editor?
jasmussen commentedon Sep 28, 2026
Thanks everyone for the detailed discussion here. The 6.6 behaviour, Global Styles block padding overriding the automatic .has-background padding, was intentional and is being kept per the consensus above. But the specific downside raised, that themes had no way to override or remove the default background padding, has been addressed in WordPress/gutenberg#82024, merged to trunk. It routes the padding through a new --wp--style--block-background-padding custom property (see packages/base-styles/_variables.scss), with the old values kept as a fallback so existing sites are unaffected. This also unifies Paragraph and Heading on the same mechanism. For that reason, closing this one as fixed!