Visitar URL original
[css-syntax-3] The `+` in `<an+b>` confuses parsing tools · Issue #9473 · w3c/csswg-drafts · GitHub
Skip to content

[css-syntax-3] The + in <an+b> confuses parsing tools #9473

Closed

Description

@tidoust

The <an+b> type is defined with a production rule that starts with <an+b> = .... This type is now referenced from the definition of :nth() in the CSS Generated Content for Paged Media Module.

Problem is that the + confuses grammar parsers, including CSSTree and the highlighting mechanism in Bikeshed (which creates a link to the definition of +), as they parse + as a component value multiplier.

The Value Syntax Definition is not entirely clear about what characters can be used to define basic data types between < and > but it says:

Other non-keyword literal characters that may appear in a component value, such as “+”, must be written enclosed in single quotes.

I think that's the only occurrence in CSS specs of a construct that parsers find problematic. Tools could be fixed of course, I'm wondering whether it would be ok to defined the type as <an-plus-b> instead.

(If so, I'm happy to prepare a PR to update the specs that define or reference the type)

Activity

  1. cdoublev commented on Oct 16, 2023

    @cdoublev
    Collaborator

    I think those tools should be able to parse any <ident> between < and >, like in the syntax descriptor.

    https://drafts.css-houdini.org/css-properties-values-api-1/#consume-a-data-type-name

  2. tabatkins commented on Oct 17, 2023

    @tabatkins
    Member

    I think it's fine to just rename it to <an-b>, honestly. The plus isn't necessary.

  3. fantasai commented on Nov 20, 2023

    @fantasai
    Collaborator

    Question about bikeshedding: as we're getting further away from the actual form of the notation "2n+1", it's getting more confusing to refer to the notation. An+B was somewhat understandable, because it pattern-matches against the notation. But <an-b> just seems like weird 1970s computer garbage naming.

    Some possible replacements:

    • <An-B> at least helps it parse as three components (a, n, b), rather than two (an, b).
    • <nth> or <ith> or <index> or something like that (it is called :nth-child())
    • other ideas?
  4. cdoublev commented on Nov 21, 2023

    @cdoublev
    Collaborator

    other ideas?

    <position-pattern>.

    I assume escaping + in an+b, which would allow to be a valid <ident> parsed by CSSTree, is excluded.

  5. tabatkins commented on Nov 21, 2023

    @tabatkins
    Member

    Yeah, we need to name that's useful to read and write; there's no reason to contort ourselves to preserve a specific name. ^_^

  6. Psychpsyo commented on Mar 15, 2026

    @Psychpsyo
    Contributor

    I like <a-n-plus-b> and <nth> the most. Maybe <nth-notation> so that it at least feels like a noun.
    Anything that involves fully lowercase an reads like the word "an" which feels weird and a bit ugly to read to me.

    <nth> or <nth-notation> would also acknowledge the fact that these can be of the form An-B as well. (or any other form that isn't strictly An+B)

  7. added and removed
    Agenda+ LaterLower-priority items that are flagged for CSSWG discussion
    on Apr 13, 2026
  8. css-meeting-bot commented on Jun 10, 2026

    @css-meeting-bot
    Member

    The CSS Working Group just discussed [css-syntax-3] The `+` in `<an+b>` confuses parsing tools, and agreed to the following:

    • RESOLVED: Use <a-n-plus-b> instead of <an+b>
    The full IRC log of that discussion <dshin-moz> TabAtkins: Quick one, to check if everyone is ok with name
    <dshin-moz> ... Some selectors use an+b syntax, production for that is <an+b>
    <dshin-moz> ... A lot of tools downstream of bikeshed do not like + in it
    <dshin-moz> ... They want some sort of identifier
    <dshin-moz> ... alphas, numerics & dashes
    <TabAtkins> <a-n-plus-b>
    <dshin-moz> ... I suggest we just write out the plus
    <emilio> +1
    <dshin-moz> ... Don't want anything abstract
    <smfr> did you mean `<an-plus-b>` ?
    <dshin-moz> ... Unless anyone have objections, I'll make the change to use it
    <dbaron> I think I prefer Tab's <a-n-plus-b>
    <dshin-moz> ... Prefer a-n to an, since that is a valid word
    <dshin-moz> ... No strong opinions, though
    <smfr> no opinion myself
    <dbaron> (I'd also be ok with <anplusb>.)
    <dshin-moz> PROPOSED: Use <a-n-plus-b> instead of <an+b>
    <dshin-moz> Rossen: objections?
    <dshin-moz> RESOLVED: Use <a-n-plus-b> instead of <an+b>
    <schenney> present-
  9. fantasai commented on Jul 22, 2026

    @fantasai
    Collaborator

    Re-opening because I think <a-n-plus-b> is just the most awkward option out of all of the ones suggested in this issue, and I'd like us to consider one of the less awkward ones. 😓

  10. tabatkins commented on Jul 22, 2026

    @tabatkins
    Member

    While I don't have a strong opinion on what we use, I don't think a-n-plus-b is particularly bad - it's exactly how we pronounce the construct already (like, we say "nth-child starts with an 'A N plus B' argument"). It's also not too long; if anything, it's on the shorter side character-wise. I think it's just striking you because, tho short, it's still four words, and one of them is us spelling out a character.

    I think we should stick with the resolution. It's how we all pronounce An+B when actually talking about it, and it's always convenient when the production is the same term as the actual definition.

  11. kbabbitt commented on Jul 22, 2026

    @kbabbitt
    Collaborator

    +1 that I don't think <a-n-plus-b> is particularly bad. I think <nth> or <nth-index> would also be fine, but I'd prefer to avoid <An-B> or other forms that rely on casing to convey meaning.

  12. svgeesus commented on Jul 30, 2026

    @svgeesus
    Collaborator

    I think we should stick with the resolution. It's how we all pronounce An+B when actually talking about it,

    I agree, it seems like a fine name to me for that reason.

  13. tabatkins commented on Oct 12, 2026

    @tabatkins
    Member

    I'm gonna go ahead and close this; I've pinged Elika privately without response, but she can open a fresh issue if she really feels strongly enough to put it in front of the WG again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions