csscss-selectors

Is whitespace required between the attribute selector sensitivty flag and a preceding token?


Regarding CSS attribute matching, is [href="http"i] legal syntax, no space between the ‘"’ and the ‘i’, or does there have to be whitespace, i.e. [href="http" i]?

The W3C Jigsaw CSS Validator says that the whitespace is required. It fails the version without the whitespace.


Solution

  • If it's a case of where to report the bug, then I can't see anything in the specification that requires a space there. The Grammar says

    <attribute-selector> = '[' <wq-name> ']' |
                           '[' <wq-name> <attr-matcher> [ <string-token> | <ident-token> ] <attr-modifier>? ']'
    

    So the requirement seems to be that the `i` be distinguishable as a separate token from the ident-token or string-token that precedes it, and in your example that requirement is met. If the preceding token was an ident-token, then the space would be needed to achieve that distinction.

    So, as far as I can see, it's a bug in the validator.