Repository navigation
Media & Text: Restore content padding in classic themes with a CSS reset - #85200
Conversation
🤖 PR meta 🤖👋 Welcome👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ariel-maidana! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. 🎉 PropsIf 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. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the |
|
Could a maintainer please add |
| // One class of specificity: theme.json and theme class rules can override it, but element resets like `div { padding: 0 }` can't. | ||
| .wp-block-media-text > :where(.wp-block-media-text__content) { |
There was a problem hiding this comment.
I wonder if we should lean into the same approach that Global Styles in general uses to achieve the 0-1-0 specificity. That is, wrapping the entire selector in :root :where(). That pattern is so common in this codebase now that it almost doesn't need the explanatory inline comment.
There was a problem hiding this comment.
Yes, let's do that
:root :where(.wp-block-media-text > .wp-block-media-text__content)|
@ariel-maidana I've added the requested labels. Looks like this will need a rebase and minor conflict resolved. I'll try and give it a review tomorrow if nobody beats me too it. |
ciampo
left a comment
There was a problem hiding this comment.
Needs a rebase + conflict solving
| // One class of specificity: theme.json and theme class rules can override it, but element resets like `div { padding: 0 }` can't. | ||
| .wp-block-media-text > :where(.wp-block-media-text__content) { |
There was a problem hiding this comment.
Yes, let's do that
:root :where(.wp-block-media-text > .wp-block-media-text__content)|
Thank you @aaronrobertshaw ! |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
I have given this a quick test.
✅ Twenty Eleven gets its 8% padding back on the front end
✅ Twenty Twenty-Five is unchanged
:root :where() versus this selector
I also tried the :root :where() version. Both are 0-1-0, and they behaved the same.
So I'd go with :root :where() to match the rest of block library, and drop the inline comment.
im3dabasia
left a comment
There was a problem hiding this comment.
+1 to the :root :where() suggestion. I tested it locally on classic and block themes, and it works as expected 👍
Once the selector is switched, the inline comment is dropped and the changelog conflict is resolved, this looks good to go.
Twenty Eleven (classic)
| Before | After |
|---|---|
![]() |
![]() |
| Customizer CSS overrides it | Theme class rule overrides it |
|---|---|
![]() |
![]() |
Twenty Twenty-Four (block)
| Default unchanged | theme.json CSS overrides it |
Site Editor CSS overrides it |
|---|---|---|
![]() |
![]() |
![]() |
Test ReportDescriptionThis report validates whether the indicated patch works as expected. Patch tested: #85200 (head cad6d39) Environment
How the patch was appliedThere is no plugin build for this PR yet: only the labelling workflows have run for cad6d39. Since the change is a single selector, I applied it to the stylesheet that WordPress 7.2 Beta 1 inlines for this block ( Steps
Actual Results
Additional Notes
Thanks @ariel-maidana for the fix. AI assistance: Yes. I used Claude (Anthropic) to set up the test environment, run the tests and draft this report, and I reviewed the results before posting. |
|
Thanks @softglazee for testing the patch! The plan is to go with this suggestion so that we get a specificity of 0,1,0. This way, we solve both the original issue and #85199. |
|
@ariel-maidana , are you able to continue the work here? |
|
@ciampo I'll make the changes and update the PR. |
|
Thanks @ciampo, @aaronrobertshaw and @im3dabasia, and @softglazee for testing. Pushed 7299ad1, which switches the rule to
The theme.json override and this rule now use the same selector shape, so they tie on specificity. The override wins because |
7299ad1 to
3ecf850
Compare
|
CI is green apart from Playwright shard 5, which hit the 45-minute job timeout without a test failure (the same timeout shows up occasionally on trunk). Could someone re-run the failed jobs? Thank you! |
aaronrobertshaw
left a comment
There was a problem hiding this comment.
Thanks for the update @ariel-maidana 👍
Looks like we'll need another rebase and a minor changelog conflict resolved. Then this should be good to go.
I re-tested after the latest changes:
✅ Twenty Eleven: the content padding is back at 8%, on the front end and in the editor. The theme's div { padding: 0 } reset no longer wins.
✅ Twenty Twenty-Five: 8% by default. With the theme.json css override from #83563, it's 0 on the front end. Both rules are 0-1-0, and the override wins because global-styles prints after the block styles.
✅ The description matches the code now.
One optional nit: the inline comment could go now, since :root :where() is the usual pattern. Might be worth doing now while you resolve the changelog conflict.
I'm happy to approve now pending those tweaks.
like `div { padding: 0 }` removed it on the front end. Keep one class of
specificity so element resets lose while theme.json and theme class rules
still override it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same 0,1,0 specificity as before, written the way Global Styles writes it, as suggested in review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The `:root :where()` pattern is standard, so it doesn't need explaining, as suggested in review. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
3ecf850 to
78b1edd
Compare
|
Thank you @aaronrobertshaw ! |
|
There was a conflict while trying to cherry-pick the commit to the wp/7.2 branch. Please resolve the conflict manually and create a PR to the wp/7.2 branch. PRs to wp/7.2 are similar to PRs to trunk, but you should base your PR on the wp/7.2 branch instead of trunk. |
|
If this PR is needed for WordPress 7.2, could someone manually create a backport PR? |
…set (#85200) (#85821) Co-authored-by: ariel-maidana <arielmaidana@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: im3dabasia1 <im3dabasia1@git.wordpress.org> Co-authored-by: softglaze <softglaze@git.wordpress.org> Co-authored-by: t-hamano <wildworks@git.wordpress.org>
…set (#85200) Co-authored-by: ariel-maidana <arielmaidana@git.wordpress.org> Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org> Co-authored-by: ciampo <mciampini@git.wordpress.org> Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org> Co-authored-by: softglazee <softglaze@git.wordpress.org>








What?
Closes #85199. Follow-up to #83563.
Raises the Media & Text content padding from zero specificity to one class (
:root :where(.wp-block-media-text > .wp-block-media-text__content)). Classic themes' CSS resets no longer remove it, and theme.json and theme styles can still override it.Why?
#83563 wrapped the default
padding: 0 8%in:where(), so it has zero specificity. Many classic themes ship the Meyer-style reset (html, body, div, … { padding: 0 }), including Twenty Eleven. The text column is adiv, so that reset (0,0,1) now beats the block's default (0,0,0). On the front end, the text sits flush against the media in every Media & Text block on the site, with no change to the content. The editor is unaffected because classic themes don't load their front-end stylesheet there.Since 24.2.0 we've had reports on WordPress.com across Penscratch 2, Argent, Cubic and Twenty Eleven. It also reproduces on a clean install with Twenty Eleven.
How?
:root :where(), the pattern Global Styles uses::root :where(.wp-block-media-text > .wp-block-media-text__content), specificity 0,1,0..entry-content .wp-block-media-text__content(0,2,0) still win.:root :where(.wp-block-media-text .wp-block-media-text__content), which is 0,1,0, a tie. It still wins because per-block global styles are attached toglobal-styles, which prints after the block's stylesheet. Tested with Twenty Twenty-Five on this branch: with the override the computed padding is 0, without it 8%. Worth a reviewer's eye in case there's a load path where that order flips.Testing Instructions
"css": "& .wp-block-media-text__content { padding: 0; }"understyles.blocks.core/media-text. Reload, and confirm the padding is removed in the editor and on the front end.Testing Instructions for Keyboard
No UI change.
Screenshots or screencast
With the fix, DevTools shows the block's rule applied and Twenty Eleven's reset
padding: 0overridden:Use of AI Tools
I used Claude Code (Claude Opus 5.5) to trace the regression to #83563, write the change and changelog entry, and draft this description. It also checked the cascade in headless Chrome against Twenty Eleven's reset and the compiled theme.json override. I reviewed the change and reproduced the bug and the fix myself.