Stefan Judisstefan
Oct 13, 2026, 2:09 PMHere's a funky learning from a couple of years ago: do you know that there's a `CSS` namespace in JavaScript that includes a method to `escape` CSS selectors?
https://www.stefanjudis.com/today-i-learned/how-to-escape-css-selectors-in-javascript/
![console.log(`.${CSS.escape("a:b")}`); // ".a\:b" console.log(`[href=${CSS.escape("@")}]`); // "[href=\@]" console.log(`.${CSS.escape("[jooo]")}`); // ".\[jooo\]"](https://cdn.masto.host/frontendsocial/media_attachments/files/117/433/994/828/862/775/small/fe79be3dd6519f42.png)