I'd like to provide a link to an external page (not under my control) that has a specific part where I want it to point to (it's a license page with an appendix, and I want the link to go directly to the appendix).
I would normally do this with a # in the URL, like this:
https://en.wikipedia.org/wiki/Fragment_identifier#Examples
This makes the page scroll to already start on the HTML element with id="Examples".
The problem is when the HTML page doesn't put an id on the elements.
Is there any other way to make the URL point to the relevant section? Do URL fragments accept only ids or can I use other CSS selectors somehow?
I think the answer simply is: you cannot.
An
idattribute on elements is required (barring very specific JavaScript features on your target page, and barring extensions that inject stuff after the fact) to link to a specific element on the page.The scrolling behavior is defined in the spec, under section "Scrolling to a fragment":
Notes:
nameattribute forais not valid in current HTML5 anymore.#fragment (as well as the#topfragment, if notopid is defined on the page) can be used to scroll to the top of the page.