-
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
Styles: Allow global styles padding to apply to blocks with background #61999
base: trunk
Are you sure you want to change the base?
Styles: Allow global styles padding to apply to blocks with background #61999
Conversation
Fixes the paragraph and list blocks.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There is a 3 year old issue about removing the automatic padding that is added when the background color is added, but it is not so simple. #30725 |
Related:
What?
This is a follow-up to #61638 to allow global styles set padding for blocks with backgrounds to apply.
Why?
Currently, the Paragraph and List blocks apply default padding when those blocks have a background color set. This is done by selectors that have a higher specificity for these blocks than the global styles. The result is the global styles set padding is overridden.
Theme authors using theme.json or users attempting to tweak spacing via global styles shouldn't have to resort to hacks setting custom css for these blocks to achieve their desired result e.g.
Important
This change, if accepted, could mean global styles rules might unintentionally override individual paragraph blocks that have a background color set. More context can be found in #61638 (comment). As noted there, this PR would likely deliver the expected behaviour and can be considered a "fix".
How?
p.has-background
andul.has-background, ol.has-background
selectors so they have0-1-0
specificity to match global styles after Styles: try wrapping with :root to fix reset styles #61638 lands.Testing Instructions
.has-background
padding for each is applied