Visitar URL original
[selectors-4] HTML and case-sensitivity · Issue #2259 · w3c/csswg-drafts · GitHub
Skip to content

[selectors-4] HTML and case-sensitivity #2259

Open

Description

@annevk

HTML has whatwg/html#3372 (in general) and whatwg/html#2738 (attr()-specific).

I'm not entirely sure what can be done here given the constraints, but I suppose at least https://drafts.csswg.org/selectors/#case-sensitive and https://drafts.csswg.org/selectors/#attribute-case could be updated to be more accurate about HTML.

(I also think it's a little misleading to talk about HTML and XML, since you can use XML elements inside HTML through scripting, but the HTML rules apply since it's an HTML document (https://dom.spec.whatwg.org/#concept-document-type).)

Activity

  1. SelenIT commented on Feb 2, 2018

    @SelenIT
    Collaborator

    Issue #2101 also is probably related.

  2. svgeesus commented on Jun 1, 2026

    @svgeesus
    Collaborator

    I'm not entirely sure what can be done here given the constraints, but I suppose at least https://drafts.csswg.org/selectors/#case-sensitive and https://drafts.csswg.org/selectors/#attribute-case could be updated to be more accurate about HTML.

    Re-animating this zombie issue.

    Selectors 4 now normatively references infra for the definition of case-insensitive:

    All Selectors syntax is ASCII case-insensitive (i.e. [a-z] and [A-Z] are equivalent), except for the parts that are not under the control of Selectors: specifically, the case-sensitivity of document language element names, attribute names, and attribute values depends on the document language.

    and also for attribute case:

    By default case-sensitivity of attribute names and values in selectors depends on the document language.

    To match attribute values ASCII case-insensitively regardless of document language rules, the attribute selector may include the identifier i before the closing bracket (]). When this flag is present, UAs must match the attribute’s value ASCII case-insensitively (i.e. [a-z] and [A-Z] are considered equivalent).

    and

    Alternately, the attribute selector may include the identifier s before the closing bracket (]); in this case the UA must match the value case-sensitively, with “identical to” semantics [INFRA], regardless of document language rules.

    The mention of HTML and XML differences are now in an example so non-normative, but referencing the HTML LS:

    Example 11:
    For example, in HTML, element and attribute names are ASCII case-insensitive, but in XML, they are case-sensitive.

    @annevk sorry you waited so long for a response. Is there still more to do here or is the wording now acceptable?

  3. annevk commented on Jun 4, 2026

    @annevk
    MemberAuthor

    It was @fantasai who filed the issue against HTML originally and I think the language in Selectors around this hasn't really changed since then (modulo the new i and s identifiers for attributes, or maybe the latter isn't in the standard yet).

    HTML has two sections detailing how attr() and Selectors work with regards to comparison: https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-the-css-'attr()'-function and https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-selectors. The requirements in there are not what you might expect when reading Selectors. It's not just the case-sensitivity that depends on the host language, but also the nature of comparison. And that doesn't just depend on the host language, but also other things such as the element type.

  4. svgeesus commented on Jun 4, 2026

    @svgeesus
    Collaborator

    @fantasai thoughts?

  5. svgeesus commented on Jul 9, 2026

    @svgeesus
    Collaborator

    Seems like this should be clarified before Selectors 4 moves to CR.

  6. tabatkins commented on Jul 13, 2026

    @tabatkins
    Member

    This is indeed precisely the sort of specific, bizarre detail that is the responsibility of the host language to define. Whether it lives in HTML or Selectors isn't particularly relevant, tho we probably should at least point Selectors to those sections, replacing the existing (apparently incorrect) example about HTML case-insensitivity.

    I've posted #14176 with a proposed fix to both make this clearer, and fix the explanation of HTML's rules. I'll merge it later this week unless anyone has objections.

  7. tabatkins commented on Jul 13, 2026

    @tabatkins
    Member

    I've also made it clearer in Values 5 that attr() matches identically to attribute selectors, so HTML can remove https://html.spec.whatwg.org/multipage/semantics-other.html#case-sensitivity-of-the-css-'attr()'-function entirely, unless y'all do end up wanting to do something special in whatwg/html#2738

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions