:target matches the current "target element", not the url fragment #37559
Labels
Content:CSS
Cascading Style Sheets docs
Content:HTML
Hypertext Markup Language docs
needs triage
Triage needed by staff and/or partners. Automatically applied when an issue is opened.
MDN URL
https://developer.mozilla.org/en-US/docs/Web/CSS/:target
What specific section or headline is this issue about?
the whole page
What information was incorrect, unhelpful, or incomplete?
The page explains that the
:target
pseudo-classThroughout the rest of the page, the examples say that the selector will match if the URL has a fragment that matches an elements id. But the target element isn't always the element with an id matching the URL fragment. SPAs make use of
pushState
/replaceState
for navigation and apparently the target element is not updated in response to these (whatwg/html#639 (comment)) so:target
will not always reflect the URL fragment.What did you expect to see?
I would expect the document to emphasize that the selector matches the "target element" and explain that it won't respond to changes in the URL.
Do you have any supporting links, references, or citations?
Do you have anything more you want to share?
No response
MDN metadata
Page report details
en-us/web/css/_colon_target
The text was updated successfully, but these errors were encountered: