Repository navigation
Media & Text: Restore content padding in classic themes with a CSS reset - #85200
ariel-maidana wants to merge 2 commits into
Conversation
WordPress#83563 gave the content padding zero specificity, so classic theme resets 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>
🤖 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. 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? |







What?
Closes #85199. Follow-up to #83563.
Raises the Media & Text content padding from zero specificity to one class (
.wp-block-media-text > :where(.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?
:where()from around the whole selector to around the child:.wp-block-media-text > :where(.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.html body :where(.wp-block-media-text > .wp-block-media-text__content). It beats a single-element reset and loses to anything with a class. Happy to switch if reviewers prefer it.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.
🤖 Generated with Claude Code