Solution 1 :

<a href="#cd">...</a> links to an element with id="cd".

You need to have a matching element to link to.

Solution 2 :

It is related to how GitHub prefixes the id of a heading in order to guard against user content clobbering elements used by CSS or JavaScript, see here for a brief explanation related to this.

then use JavaScript to perform the actual scrolling to user content.

Problem :

Both links with following anchor-ed a tags:

<a id="user-content-cd" class="anchor" aria-hidden="true" href="#cd"></a>

Why Github works with #cd (Jump to H2 of cd section):

But this one does not work:



Comment posted by Turnip

The anchor on GitHub actually links to this element

Comment posted by Quentin

They’ve got a bunch of obfuscated JavaScript. It’s probably something to do with that. There’s no reason to use JS instead of plain HTML for that though.


Leave a Reply

Your email address will not be published. Required fields are marked *