Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Media Queries applied to blocks custom css are not working in gutenberg >=16.8.0 | GoodFirstPicks

Media Queries applied to blocks custom css are not working in gutenberg >=16.8.0

WordPress/gutenberg 10 comments 27d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeTest focusedWordPressJavaScriptReact

Why this is a good first issue

Media queries in custom CSS for Gutenberg blocks are not being applied correctly.

AI Summary

The issue involves media queries in custom CSS for Gutenberg blocks not being applied correctly, particularly after updating to Gutenberg 16.8.0 and later versions. The problem appears to be related to how media queries are processed or applied within the block styles. Reproduction steps are provided, but the root cause is not immediately clear, requiring investigation into CSS handling in Gutenberg.

Issue Description

Description

I have a query pagination that looks like this: image I opted to hide the pagination numbers with a media query applied as custom CSS in the core/query-pagination-numbers block style.

@media screen and (max-width: 599px) {
  & .page-numbers {
    display: none;
  }
}

But after updating gutenberg from 16.7.1 to 16.8.0 (and 16.8.1 now) I noted that my query pagination numbers were also hidden on higher resolutions with a display: none applied. image

image

This is in theme.json in styles.blocks.core/query-pagination-numbers.css

"css": "& .page-numbers.current { padding: .5rem .7rem; border-radius: .25rem; color: var(--wp--preset--color--query-pagination-numbers-current-contrast); background-color: var(--wp--preset--color--query-pagination-numbers-current-base); } & .page-numbers.dots { padding: .5rem .6rem; border-radius: .25rem; color: var(--wp--preset--color--query-pagination-numbers-dots-contrast); background-color: var(--wp--preset--color--query-pagination-numbers-dots-base); } @media screen and (max-width: 599px) { & .page-numbers { display: none; } }",

It's like the media query fragment is completely ignored, bypassed. But not it's CSS inside that's still applied without resolution constraints.

To demonstrate it, I changed the media query code to @media screen and (max-width: 599px) { & .page-numbers { color: #f00; } }

image

And as you can see, that css inside the media query is still being applied in a 1024 resolution.

The theme is custom, made by me... But since it's working on 16.7.1 and only failed when I

GitHub Labels

[Type] BugGood First Issue[Feature] Custom Editor StylesCSS Styling

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • CSS specificity
  • media query handling
  • potential regression
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedyes