Skip to content

Fix invalid media query (not(hover)) -> (hover: none)#228

Closed
BurtReynolds wants to merge 1 commit into
jdan:mainfrom
BurtReynolds:fix/invalid-media-query-not-hover
Closed

Fix invalid media query (not(hover)) -> (hover: none)#228
BurtReynolds wants to merge 1 commit into
jdan:mainfrom
BurtReynolds:fix/invalid-media-query-not-hover

Conversation

@BurtReynolds

Copy link
Copy Markdown

@media (not(hover)) is not valid CSS. The not keyword in a media query must be followed by whitespace per Media Queries Level 4, so not(hover) parses as a function and is rejected.

PostCSS (used by this repo's build) tolerates it, but stricter tools do not, so the published file can't be consumed in practice:

(hover: none) expresses the same intent (target devices whose primary input cannot hover) without the not keyword, and parses cleanly in PostCSS, Dart Sass, and Lightning CSS.

Fixes #218, #223

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@jackmorgansplunk is attempting to deploy a commit to the jdan's projects Team on Vercel.

A member of the Team first needs to authorize it.

`@media (not(hover))` is not valid CSS. The `not` keyword in a media
query must be followed by whitespace per Media Queries Level 4, so
`not(hover)` parses as a function and is rejected.

PostCSS (used by this repo's build) tolerates it, but stricter tools
do not, so the published file can't be consumed in practice:

- Dart Sass (Next.js, Vite, etc.) throws "Expected whitespace",
  breaking `@include meta.load-css(...)` scoping (jdan#223)
- Lightning CSS reports InvalidMediaQuery, preventing import (jdan#218)
- The W3C validator rejects it (jdan#218)

`(hover: none)` expresses the same intent (target devices whose
primary input cannot hover) without the `not` keyword, and parses
cleanly in PostCSS, Dart Sass, and Lightning CSS.

Fixes jdan#218, jdan#223
@BurtReynolds BurtReynolds force-pushed the fix/invalid-media-query-not-hover branch from 2a430bb to 1ed8f5d Compare June 25, 2026 07:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Syntax error - Invalid media query

1 participant