Markdown Links

Written by Last updated

A Markdown link is the link text in square brackets followed by the destination in parentheses: [text](url). The destination can be a web address, a file in your project, an email address or a heading in the same file.

This guide covers every link type, plus two things most guides skip: adding a tooltip, and opening a link in a new tab. For pictures, see the image syntax page.

🟒 Practice as you read: Open the Markdown Editor to test each example, or use the Markdown Link Generator to build one quickly.

Open EditorDownload PDF

Syntax at a glance

Link type Syntax
Inline [Text](https://example.com)
With a tooltip [Text](https://example.com "Tooltip")
Reference [Text][ref] plus [ref]: https://example.com
Autolink <https://example.com>
Email <name@example.com> or [Email us](mailto:name@example.com)
Relative [Guide](docs/guide.md)
Root-relative [Lists](/markdown-lists)
Heading in this file [Jump](#installation)
Heading in another file [Install](docs/guide.md#installation)
Image as link [![Alt](image.png)](https://example.com)

Open a link in a new tab

Markdown has no syntax for this. Plain [text](url) follows the platform's default behaviour. If your platform allows HTML, use an <a> tag:

<a href="https://example.com" target="_blank" rel="noopener">Visit site</a>

Check first that your platform does not sanitize HTML. Some remove the target attribute, and GitHub is likely one of them, so the link will open in the same tab there. For other HTML limits, see what gets stripped.

URLs with spaces or parentheses

A space or an unbalanced parenthesis ends the URL early and breaks the link.

Problem Fix
Space in the path Wrap the path in angle brackets, [Guide](<my guide.md>), or write %20. Better: rename the file with hyphens.
Parenthesis in the URL Write it as %28 and %29, or escape with a backslash.

Common mistakes

Mistake Fix
Missing closing parenthesis: [GitHub](https://github.com [GitHub](https://github.com)
Empty link text: [](https://example.com) [Project website](https://example.com)
Wrong relative path: [Guide](guide.md) when the file is in docs/ [Guide](docs/guide.md)
Space between ] and ( Remove it: [Text](url)
Anchor does not match the heading Check capitalization, punctuation and duplicate headings.

Where each link type works

Inline, reference and relative links work in GitHub, GitLab, VS Code and Obsidian. Bare-URL autolinks need a GFM-style renderer. Obsidian also has its own [[wikilink]] syntax, which other tools do not read. For chat and note apps, check the app's own docs.

Frequently Asked Questions

  1. 1

    How do I link to a heading in another Markdown file?

    Write the path, then # and the heading's anchor: [Install](docs/guide.md#installation). The anchor has to match the heading in the other file exactly, so renaming that heading breaks the link.

  2. 2

    How do I put a space or parenthesis in a Markdown link URL?

    Wrap the URL in angle brackets, [Guide](<my guide.md>), or encode the characters: %20 for a space, %28 and %29 for parentheses. Renaming files to use hyphens avoids the problem.

  3. 3

    Why isn't my heading link working?

    The anchor does not match the heading. GitHub lowercases the heading, drops punctuation and turns spaces into hyphens, and adds -1 to duplicate headings. Copy the anchor from the rendered page, or check the anchor rules on the Markdown Headings page.

  4. 4

    Why is a plain URL not clickable?

    Clickable bare URLs are a GFM extension. A strict CommonMark renderer shows them as text. Wrap the URL in angle brackets, <https://example.com>, and it works everywhere.

  5. 5

    Can link text be bold or code?

    Yes. Put the formatting inside the brackets: [**Bold**](url) or [`code`](url). Do not wrap the whole link in the formatting unless you want the same effect on the brackets.