Alexis Wilke
Alexis Wilke

Reputation: 20720

How is the || operator used in CSS?

CSS3 added the <column-token> operator as follow:

<column-token>: ||

It also says:

<column-token> has been added, to keep Selectors parsing in single-token lookahead.

So, is that just an artifact of the lexer, or is that an actual operator used for something I do not know about yet?

Upvotes: 1

Views: 279

Answers (2)

Tgr
Tgr

Reputation: 28160

CSS level 4 does in fact have a column operator (used to select table cells of a column).

No idea if that's related and the token was added to CSS3 to be forward-compatile - it would be strange, but then the naming does not sound coincidental. The argument for the new token was indeed parsing convenience:

I just added a COLUMN token to the Syntax draft, matching "||". It's needed for Selectors, so it can maintain LL(1). (Otherwise, seeing "*" followed by "|" is ambiguous until you look at the next token.)

Which I admit I don't quite understand. What else could *| be interpreted as, even in CSS4? There is no other valid use of | in a selector (except inside an attribute matcher, but there there is no valid use for ||). CSS4 Values uses both *, | and || but that's not the spec the email was referring to.

Upvotes: 1

Oskar Szura
Oskar Szura

Reputation: 2549

This is not strictly a CSS3 feature, column-token is just one of many tokens used to parse currently interpreted CSS stylesheet by CSS parser. So it has no use for you unless you're implementing a CSS parser.

Upvotes: 0

Related Questions