What is the shortest selector (by character count) to select ALL html elements on a web page, without using asterisk (*)? Some examples are the following:

a,:not(a) /*9 chars*/

:nth-child(n) /*12 chars*/

:link,:not(:link) /*17 chars*/
  • 9
    \$\begingroup\$ In Firefox at least, there's no HTML · element (it's an illegal tag name), so could you shorten a,:not(a) to :not(·)? \$\endgroup\$
    – Neil
    Oct 28 at 19:37
  • 1
    \$\begingroup\$ @Neil That's interesting. What is the significance of the middle dot character (U+00B7)? Was it just a random character you chose? \$\endgroup\$ Oct 28 at 19:43
  • 1
    \$\begingroup\$ It was the first one I found where document.createElement threw an error but :not did not. \$\endgroup\$
    – Neil
    Oct 28 at 19:44
  • 1
    \$\begingroup\$ @Neil After playing around with some more special symbols, I was curious to know if there were any "standard" symbols could be typed from a keyboard. The only symbol I could get to work that exists on a keyboard is a double backslash: :not(\\). I wonder why and how that works, but something like :not(^) does not. \$\endgroup\$ Oct 28 at 20:07
  • \$\begingroup\$ @Neil Update: other characters also work when preceded by a backslash, for example :not(\*) and :not(\#) \$\endgroup\$ Oct 28 at 20:15


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.