How to add an ID to a header in Markdown

You might need to add custom IDs to a header for many reasons. Whether it’s to style it in CSS or to link to that section.

In order to add the ID to the header in markdown, you put the ID in curly brackets like in this example:

# Linking to your custom ID in Markdown {#put-id-here}

This creates the following HTML

<h1 id="put-id-here">Linking to your custom ID in Markdown</h1>

Linking to your custom ID in Markdown

Now you can link to that heading in markdown by doing [link text here](#put-id-here). Example: link text here. This creates the following HTML:

<a href="#put-id-here">link text here</a>

In case, your markdown processor doesn’t support the above, you can just use the HTML that gets generated.

Looking to learn how to code and make money online? Check out CodingPhase (referral link)