Skip to content

[css-selectors] Support . (dot) notation for non-XHTML namespaces #534

@sebastien

Description

@sebastien

Regarding https://drafts.csswg.org/selectors-4/#class-html

Browsers currently render CSS stylesheets using the .classname (dot notation) differently from the [class~="classname"] notation depending on the node's namespace.

For instance, Firefox treats both cases the same for non-XHTML XML nodes while Chrome only applies the [class~=...] form in http://ffctn.com/doc/chrome-test-style.xml

The issue has been around for a while (see Bugzilla #7758 and Chromium #69444), and boils down to this:

  • The spec is clear in saying that dot-notation is meant for (X)HTML nodes
  • However, the common practice is that developers prefer/use the dot-notation
  • Developers willing to use CSS stylesheets for non-XHTML namespace XML currently can't reliably use the dot-notation because of the different interpretations by browsers
  • As a result, one option to do so would be to write the CSS in dot-notation and then transpile it to [class=~...] notation, which would lead to having either two stylesheets (one per notation) or a default stylesheet in [class=~...] notation instead of the dot-notation.

Given that the dot notation is an alternative syntax to the [class=~...] (at least according to this comment), it would be good if it had the same treatment across all browsers.

Ultimately, I feel XML does not deserve to be treated as a second-class citizen of the web, and would benefit get the same level of tooling support as HTML. Maybe the spec can help by clarifying that if an XML node has a class attribute, then any corresponding dot-notation CSS selector should match?

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