markdownlint/doc/md051.md

967 B

MD051 - Link fragments should be valid

Tags: links

Aliases: link-fragments

This rule is triggered when a link fragment does not correspond to a heading in the document:

# Title

[Link](#fragment)

To fix the issue, change the fragment to reference an existing heading:

[Link](#title)

Alternatively, an HTML a tag with an id (or a name) attribute defines a valid anchor:

<a id="fragment"></a>

Some platforms (e.g., GitHub) automatically create HTML anchors for every heading. This makes it easy to link to different sections in a document. These internal links can break over time as headings are renamed.

Note: Creating anchors for headings is not part of the CommonMark specification.