scroll-to-css-selector
scroll-to-css-selector copied to clipboard
Explainer for supporting CSS selectors when navigating to a URL fragment
In CSS, the `:target` pseudo-class can be used to style the currently-targeted element, i.e. the element with an `id` matching the URL fragment. Do we want to extend `:target` to...
Alternatives: * `target=.foo` - matches `:target`. * `=.foo` - short, but maybe unclear. * `css(.foo)` - short, but maybe introduces parsing issues since `(` is part of CSS
This proposal make me recall the old XPointer spec: https://www.w3.org/TR/xptr-framework/ and the (not very old) proposal from : http://simonstl.com/articles/cssFragID.html , which is also mentioned in the end of README. I'm...
Some pseudo-classes (`:first-child`, `:nth-child`…) make perfect sense as target selectors. Others, not so much: `:valid`, `:hover`, `:lang()`. Likewise, most pseudo-elements don't work well as targets (`::before`, `::after`), but we could...
`targetElement=.foo&bar` Does the selector parsing end at `&`? It feels like it should if you're going with a urlencoded style.
Is it worth adding a mention that there's a potential usability dependency on URL parsing libs/algorithms being updated? Commonly used services which will identify & link a URL in a...
```js const selectors = new URLSearchParams(window.location.hash.slice(1)).get('target') const element = selectors && document.querySelector(selectors) if (element) { element.scrollIntoView() } ```
The proposal in this repo is close enough to an existing W3C Note, so I'd like to suggest to simply reconsider reusing that and extending whatever is necessary: [W3C Selectors...