Markdown Links

How to add links in Markdown — inline, reference, auto-links, and anchors

Open in New Tab

Standard Markdown has no syntax for opening a link in a new tab. To get this behavior, use inline HTML with target="_blank".

<a href="https://github.com" target="_blank" rel="noopener">Open GitHub in a new tab</a>

Always include rel="noopener" alongside target="_blank" for security. This prevents the opened page from accessing your page’s window.opener object.

Keep in mind that some platforms strip HTML attributes for security. GitHub README files, for example, remove target="_blank". This workaround is most useful when you control the Markdown renderer, such as in a static site generator, a wiki, or a desktop app like MDViewer.

Platform Support

Not every link syntax works on every platform. This table shows what you can rely on.

SyntaxGitHubGitLabVS CodeObsidianMDViewer
[text](url)YesYesYesYesYes
[text](url "title")YesYesYesYesYes
[text][ref]YesYesYesYesYes
<url> auto-linkYesYesYesYesYes
Bare URL auto-linkYesYesYesYesYes
[text](#anchor)YesYesYesYesYes
Relative linksYesYesYesYesYes
target="_blank" HTMLNo*YesNoNoYes

* GitHub strips target attributes from rendered Markdown for security. The link still works but opens in the same tab.

Common Mistakes

Forgetting the protocol

A link without https:// is treated as a relative path, not an external URL. The result is a broken link pointing to a file in your repository.

MarkdownResult
[Site](https://example.com)Links to example.com
[Site](example.com)Broken — treated as a relative path
[Site](https://example.com)   <-- correct
[Site](example.com)           <-- broken, missing https://

Space between brackets and parentheses

Adding a space between ] and ( breaks the link. The closing bracket and opening parenthesis must be adjacent.

[GitHub](https://github.com)    <-- works
[GitHub] (https://github.com)   <-- broken, space between ] and (

Wrong bracket order

Swapping the brackets and parentheses — putting the URL in square brackets and the text in parentheses — produces literal text instead of a link.

[Click here](https://example.com)    <-- correct
(Click here)[https://example.com]    <-- wrong order, renders as plain text

Parentheses in URLs

URLs that contain parentheses (like Wikipedia links) break the syntax because Markdown sees the first ) as the end of the URL. Escape inner parentheses with \ or use angle brackets:

[Markdown](https://en.wikipedia.org/wiki/Markdown_(software\))

[Markdown](<https://en.wikipedia.org/wiki/Markdown_(software)>)

FAQ

How do I make a clickable link in Markdown?

Use the inline link syntax: [link text](https://example.com). The text inside the square brackets becomes the clickable text, and the URL inside the parentheses is the destination. For example, [Visit GitHub](https://github.com) renders as a clickable “Visit GitHub” link.

Can Markdown links open in a new tab?

Standard Markdown does not support opening links in a new tab. You need to use raw HTML: <a href="https://example.com" target="_blank" rel="noopener">link text</a>. Most Markdown processors that allow inline HTML will render this correctly. Some platforms like GitHub strip the target attribute for security reasons.

What is a reference-style link?

A reference-style link separates the link text from the URL. You write [link text][id] in the body, then define [id]: https://example.com elsewhere in the document. This keeps paragraphs readable and lets you reuse the same URL in multiple places without repeating it.

How do I link to another file in the same repo?

Use a relative path: [Setup Guide](./docs/setup.md) or [README](../README.md). Relative links work on GitHub, GitLab, and most Markdown renderers. Use ./ for files in the same directory and ../ to go up a level. This keeps links working even when the repository is cloned or forked.

Do Markdown links work in all apps?

Inline links [text](url) work in every Markdown processor. Reference-style links are supported nearly everywhere. Auto-links with angle brackets are part of the CommonMark spec. Bare URL auto-linking depends on the platform — GitHub and most modern editors support it, but strict CommonMark processors do not.

How do I add an anchor link in Markdown?

Link to a heading on the same page with [text](#heading-id). The heading ID is generated automatically: convert the heading text to lowercase, replace spaces with hyphens, and remove punctuation. For example, ## Getting Started becomes #getting-started. Use [Jump to Getting Started](#getting-started) to link to it.

Preview Your Markdown Links with MDViewer

MDViewer is a native macOS app that renders your Markdown files instantly. Links in your documents are fully clickable in the preview — external URLs open in your browser, relative links navigate between files, and anchor links jump to the right section. Double-click any .md file in Finder and see every link working exactly as your readers will.

Download MDViewer

Requires macOS 13.0 or later. Intel and Apple Silicon.