From 1570119ab8be798f25cbaf81b933e8258c2bbaa6 Mon Sep 17 00:00:00 2001 From: Christopher Kirk-Nielsen Date: Wed, 1 Jan 2025 13:45:12 -0500 Subject: [PATCH] Add note about parens in matchMedia I was bitten by this and didn't find an explicit callout to help developers who might have been in my situation and could not understand why their code wouldn't work. --- files/en-us/web/api/window/matchmedia/index.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/en-us/web/api/window/matchmedia/index.md b/files/en-us/web/api/window/matchmedia/index.md index e68f396bb7af5e3..7cb22050e3a007e 100644 --- a/files/en-us/web/api/window/matchmedia/index.md +++ b/files/en-us/web/api/window/matchmedia/index.md @@ -24,6 +24,9 @@ matchMedia(mediaQueryString) - `mediaQueryString` - : A string specifying the media query to parse into a {{domxref("MediaQueryList")}}. + +> [!NOTE] +> Each `mediaQueryString` condition must be wrapped in parentheses, for example: `matchMedia('(min-width: 600px)')` will work, whereas `matchMedia('min-width: 600px')` will not! ### Return value