Skip to content

Can't distinguish HTML and non-HTML documents in UA stylesheets #44886

Closed

Description

@avis137

In some cases certain UA style rules are only expected to apply on HTML documents.
For example in https://html.spec.whatwg.org/multipage/rendering.html#tables-2, the spec expects the :is(table, thead, tbody, tfoot, tr) > form { display: none !important; } rule to only apply on HTML documents.
However, there isn't currently any way to distinguish between HTML and non-HTML documents in stylesheets, as such it is impossible to currently apply this rule. This means that either one of the /html/rendering/non-replaced-elements/tables/form-in-tables{-xhtml.xhtml, .html} WPT tests fail (the XHTML tests since #44837).

Gecko has a special :-moz-is-html pseudo class for this (https://github.com/servo/stylo/blob/71c42fd1ed99b759c5b6c7cbd407a39fb8d3a701/style/gecko/non_ts_pseudo_class_list.rs#L105-L113) but other approaches are possible.

Activity

  1. simonwuelker commented on May 13, 2026

    @simonwuelker
    Member

    Would it make sense to simply include different UA stylesheets for HTML and XML documents?

  2. avis137 commented on May 13, 2026

    @avis137
    ContributorAuthor

    I don't know if there is some reason not to do that, but it does appear a lot simpler than having a separate pseudo-class. As far as I can find, it appears that the only use of the :-moz-is-html is the above different handling of forms in a table, so it unclear why Gecko has this, as an extra stylesheet would indeed seemingly to make more sense.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions