Re: [csswg-drafts] Make it easier to express ranges for <An+B> selectors (#4140)

Ok, so let's make up some examples with your and my syntax for clarification:

matching | current syntax | first proposed syntax | second proposed syntax
------------ | ------------- | ------------- | -------------
Match the first three elements | `:nth-child(-n+3)` | `:nth-child(n <= 3)` | `:nth-child(n, n <= 3)`
Match every even element up to the eighth | `:nth-child(even):nth-child(-n+8)` | `:nth-child(even <= 8)` | `:nth-child(even, n <= 4)`
Match every third element between the sixth and the fifteenth | `:nth-child(2n+3):nth-child(-n+15)` | `:nth-child(3 <= odd <= 15)` | `:nth-child(2n+3, n <= 7)`
Match every third element starting with the second one and ending at the third last | `:nth-child(3n+2):nth-last-child(n+3)` | - | -

If we want to simplify the last example as well, we might introduce negative values to count from the last element. Using my proposed syntax this would then look like `:nth-child(3n+2 <= -3)`. Or, because of the mathematical incorrectness, there could be an additional `last` keyword, which would result in `:nth-child(3n+2 <= last-3)`, which looks quite readable, IMHO.

Sebastian

-- 
GitHub Notification of comment by SebastianZ
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4140#issuecomment-517857973 using your GitHub account

Received on Friday, 2 August 2019 22:08:11 UTC