Markdown Link Syntax: Inline, Reference, Autolinks, Relative Paths and New Tabs

Every way to write a link in Markdown, with copy-paste examples: inline, reference-style, autolinks, relative file links, image links, mailto, opening in a new tab, and the cases where links break.

The basic Markdown link is square brackets for the text and parentheses for the URL:

[Markdown Tools](https://www.markdowntools.com)

That renders as Markdown Tools. Everything else on this page is a variation on that, plus the situations where it fails.

Quick reference

You want Write
Inline link [text](https://example.com)
Link with hover title [text](https://example.com "Title")
Reference link [text][id] and later [id]: https://example.com
Autolink <https://example.com>
Email link <name@example.com> or [email me](mailto:name@example.com)
Link to a heading [text](#heading-id)
Relative file link [text](./docs/setup.md)
Image that is a link [![alt text](image.png)](https://example.com)
Open in a new tab HTML only: <a href="https://example.com" target="_blank" rel="noopener">text</a>

The optional title goes after the URL in quotes. Most renderers show it as a tooltip:

[GitHub Flavored Markdown spec](https://github.github.com/gfm/ "GFM spec")

Reference links keep long URLs out of your sentences and let you reuse one URL many times. The definition can sit anywhere in the document, and the label is not case sensitive:

Read the [spec][gfm] first. The [GFM][gfm] spec also covers tables.

[gfm]: https://github.github.com/gfm/

Definitions are not displayed in the output. If a definition shows up as text, there is usually a typo in the label or a missing colon.

Wrapping a URL in angle brackets makes it a link with the URL as its text:

<https://www.markdowntools.com>

GitHub Flavored Markdown also turns bare URLs such as https://example.com into links without brackets. Original Markdown and strict CommonMark do not, so use the angle brackets if the content will be rendered elsewhere.

In a repository or docs folder, link to other files with a relative path:

[Setup guide](./docs/setup.md)
[Parent folder readme](../README.md)
[Section of another file](./docs/setup.md#install)

These work on GitHub and in most static site generators, but a site generator that rewrites .md files to /setup/ URLs may need the path without the extension. Check the output, not just the editor preview.

[Jump to rules](#the-rules)

The id is the heading text lowercased, with spaces turned into hyphens and punctuation removed. #Title with a capital letter will not match on GitHub, which lowercases ids. Details and edge cases, such as duplicate headings, are in Markdown link to section and Markdown internal links.

Put an image inside the link text. The image syntax is the link syntax with a ! in front:

[![Build status](https://example.com/badge.svg)](https://example.com/builds)

Markdown has no syntax for target="_blank". You have three options:

  1. Write the link as HTML, as in the reference table. Add rel="noopener".
  2. Use a renderer with attribute syntax. Pandoc takes [text](url){target="_blank"} and kramdown takes {:target="_blank"} after the link. The syntax differs per tool, so this is not portable.
  3. Leave it alone. Many usability guides prefer letting readers choose how links open.

Note that GitHub strips target from links in issues, comments and READMEs, so the HTML trick only works on sites that allow it.

URLs with spaces and parentheses

A space in the URL ends the link early. Encode it as %20, or wrap the URL in angle brackets:

[Report](<./my docs/report 2026.pdf>)
[Report](./my%20docs/report%202026.pdf)

Parentheses inside a URL, as in many Wikipedia addresses, can break the link. Escape them with a backslash or use %28 and %29:

[Markdown on Wikipedia](https://en.wikipedia.org/wiki/Markdown_(disambiguation\))
Problem Likely cause
Shows [text](url) literally A backslash before a bracket, the link is inside a code span, or the renderer is not Markdown
Link ends partway through the URL Unescaped space or parenthesis
Heading link does nothing Wrong id: wrong case, or an extra hyphen or punctuation
Relative link 404s on the site The site rewrites paths, so link to the published URL form
Works in the editor, not in Slack Slack uses <https://example.com|text> or its own link dialog, not Markdown

For the Slack case, the Markdown to Slack converter rewrites links for you. The same applies to Jira and Confluence, which each have their own link syntax.

Before publishing, preview the result in the Markdown Editor, look at the generated markup with the Markdown to HTML converter, or run the text through the Markdown Linter. For a contents list that links to every heading, use the Table of Contents generator.