https://github.com/bryanmcquade/scroll-to-css-selector proposes that selectors be encoded in the URL fragment using an approach similar to query parameters.
Specifically: #targetElement=<selector>
Going forward we anticipate we'll want to encode some additional params, in addition to targetElement. For example, the explainer mentions adding support for specifying whether the target element should be 'highlighted' in the browser and this would be best encoded in a separate 'param' in the fragment, e.g. #targetElement=<selector>&targetHighlight=true
Given this, we need to ensure that any ampersands in the selector are escaped such that they don't collide with our future use of the ampersand character to specify additional key=value argument pairs in the fragment.