Hacker News new | ask | show | jobs
by kid64 1067 days ago
No. As of 2022[1], the CSS spec defines a class-name (in a .css rule's selector) as "." + ident, and the lexical scanner rules for ident specifially allow any character outside of 0x00-0x7F in a class name after an initial [_A-Za-z] character.

[1] https://www.w3.org/TR/selectors-3/#w3cselgrammar

2 comments

From my reading you can use any valid non-ascii character for the initial one too:

  ident     [-]?{nmstart}{nmchar}*
  nmstart   [_a-z]|{nonascii}|{escape}
  nonascii  [^\0-\177]
  unicode   \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
  escape    {unicode}|\\[^\n\r\f0-9a-f]
  nmchar    [_a-z0-9-]|{nonascii}|{escape}
(nmstart being the key definition for this point)
So why does this tailwind class fail?

document.querySelector('.[&_a]:underline')