W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2020

[csswg-drafts] [selectors] Does :target match newly created elements? (#5619)

From: Lea Verou via GitHub <sysbot+gh@w3.org>
Date: Wed, 14 Oct 2020 16:51:29 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-721622560-1602694288-sysbot+gh@w3.org>
LeaVerou has just created a new issue for https://github.com/w3c/csswg-drafts:

== [selectors] Does :target match newly created elements? ==
If at document load there was no element matching the URL fragment, but one is created later, does `:target` match this element?

It appears that `:target` is mentioned in both [our Selectors spec](https://www.w3.org/TR/selectors/#the-target-pseudo), and the [WHATWG HTML spec](https://html.spec.whatwg.org/multipage/browsing-the-web.html#scroll-to-the-fragment-identifier). 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](https://bugs.chromium.org/p/chromium/issues/detail?id=98561) 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](https://codepen.io/leaverou/pen/pobgyQw))

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/5619 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 14 October 2020 16:51:31 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:42:20 UTC