Skip to content

[selectors] Does :target match elements with ids that were set after hashchange time? #5619

@LeaVerou

Description

@LeaVerou

If at document load or at hashchange time there was no element matching the URL fragment, but one is created later (or an id is changed to one that matches), does :target match this element?

It appears that :target is mentioned in both our Selectors spec, and the WHATWG HTML spec. Our spec seems to imply that :target should match in that case (which is on par with the reactive way CSS selectors typically work), whereas the WHATWG spec seems to imply that if the UA is not required to scroll, :target shouldn't match either.

Due to this, this Chrome bug was closed as invalid, so if this is not the desired behavior, we should probably resolve. In terms of browser behavior, Blink, Gecko, and WebKit seem to be in agreement that delayed ids do not affect :target matching (testcase)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions