This doesn't work:

<a href="#answer">What's in the box?</a>
<details>
<summary>The box</summary>
<div id="answer">A lovely surprise!</div>
</details>

Clicking on the link doesn't navigate to the ID because it isn't visible until the details element is opened.

I'm sure it could work using JS - but is there a plain #HTML way to do this?

@Edent I found this, which would let you change the css based on a regex of the page url (i.e. if it contained a given hash link) but doesn't look like it'll make it into the final specs - or at least not for a while

https://www.quackit.com/css/at-rules/css_document_at-rule.cfm

CSS @document At-Rule