Inline links: the syntax you will use 90% of the time
The basic form is square brackets around the visible text, then parentheses around the destination:
Read the [Markdown guide](https://mdeditor.tw/markdown-guide) first.
- Square brackets hold the text, parentheses hold the URL, and no space sits between them.
- Reference links move long or repeated URLs to the bottom of the file.
- An anchor such as
#setting-up-your-api-keyis the heading text lowercased, stripped of punctuation and joined with hyphens. - Full-width brackets from a Chinese IME look right and render as nothing at all.
Why one space breaks the whole link
There is no space between ] and (. That single space is the most common link failure in Markdown. It does not raise an error either. You just get visible brackets in the middle of your text.
Adding a title attribute
A quoted string after the URL becomes the HTML title attribute. Browsers show it as a tooltip on hover:
[Markdown guide](https://mdeditor.tw/markdown-guide "Every element, explained")
Single quotes and parentheses work as delimiters too, but double quotes are the convention. Use titles sparingly. Tooltips are invisible on touch devices and unreliable for screen readers, so a title must never carry information the link text lacks.
Formatting inside link text
Link text accepts inline Markdown, so you can emphasise or code-format part of it. The rules are the ones in the bold and italic reference:
See the [**required** `--force` flag](https://example.com/docs/flags).
You cannot nest a link inside another link. The parser closes at the first ] it can match, which leaves a broken half-link on the page.
Reference-style links and when they help
Reference links separate the label from the destination. You write [text][id] in the prose, then define [id]: url elsewhere in the document:
Both the [style guide][style] and the [API reference][api]
are generated from the same source, and the [style guide][style]
is reviewed each quarter.
[style]: https://example.com/handbook/style-guide
[api]: https://example.com/developers/reference/v3/endpoints
Definitions never appear in the output. They can sit anywhere, though the bottom of the file is the convention, and the identifiers are case-insensitive.
Two shorthands, one of them risky
- A collapsed reference,
[Markdown guide][], uses the link text as the identifier. - A shortcut reference,
[Markdown guide], drops the second bracket pair and still resolves if a definition exists.
Shortcuts are elegant but risky. Any bracketed phrase turns into a link the moment someone defines that name.
When they earn their keep
Reference links pay off in three situations:
- The same URL appears several times and you want one place to update it.
- The URL is long enough to wreck the raw line and make the file hard to read.
- The file is reviewed as a diff, so a URL change touches one line at the bottom instead of a line of prose.
For a one-off link, inline is simpler. That is also why the examples in the complete Markdown guide stay inline unless a URL repeats.
Autolinks and bare URLs
When you want the URL itself to be the visible text, wrap it in angle brackets:
Docs live at <https://mdeditor.tw/markdown-guide>.
This is a CommonMark autolink. It needs a full scheme, such as https:, mailto: or ftp:. So <example.com> does not work, and it may even be swallowed as an unknown HTML tag.
Bare URLs are a GitHub extension
GitHub Flavored Markdown adds a looser rule. A bare URL in running text is linkified for you, with no brackets at all:
Docs live at https://mdeditor.tw/markdown-guide and are updated weekly.
Watch out: plain CommonMark, Markdown.pl and several minimal renderers leave a bare URL as plain text. If a document has to look the same everywhere, use angle brackets or a full inline link. The platform comparison shows which tools linkify and which do not.
GFM's autolinker is also literal about punctuation. A trailing comma or full stop is left out of the link. A trailing closing parenthesis often is not.
Relative and absolute URLs
An absolute URL includes the scheme and the host, so it means the same thing from anywhere: https://example.com/docs/setup. A relative URL resolves against wherever the current document lives. That is both its power and its problem.
[Contributing guide](CONTRIBUTING.md)
[Setup instructions](docs/setup.md)
[Back to the root readme](../README.md)
The repo view versus the published site
Inside a GitHub repository these work perfectly. GitHub resolves the path against the file's own directory.
Trouble starts when the same files are published by a static site generator. Most generators rewrite docs/setup.md into a clean URL such as /docs/setup/, so a hand-written link to setup.md can 404 on the live site. MkDocs and Docusaurus rewrite .md targets for you, which is why their docs tell you to keep the extension. Other setups do not.
Three path rules worth memorising
- No leading slash inside a repo. In a browser
/docs/setupmeans the root of the domain, but a repository view may resolve it against the repository root. - Absolute URLs for anything shown in two places, such as a README that also appears on npmjs.com.
- Match the case exactly. The servers hosting most static sites are case-sensitive even when your laptop is not, so
Setup.mdandsetup.mdare one file locally and two URLs in production.
Anchor links to headings
An anchor link jumps to a heading instead of loading a new page. The destination is a # followed by the heading's generated ID:
Jump to [installation](#installation) or [troubleshooting](#troubleshooting).
You do not create those IDs. GitHub and most renderers generate one per heading, using rules you can apply by hand. The headings reference covers the same rules from the heading side.
How a heading ID is generated: a worked example
Take this heading:
## Setting Up Your API Key (v2)
The renderer applies four steps in order:
- Strip the heading markers, leaving
Setting Up Your API Key (v2) - Lowercase everything:
setting up your api key (v2) - Remove punctuation that is not a letter, number, space, hyphen or underscore:
setting up your api key v2 - Replace spaces with hyphens:
setting-up-your-api-key-v2
So the link is:
[Set up your key](#setting-up-your-api-key-v2)
Duplicates, CJK headings and other renderers
- A second heading with the same text gets
-1appended, a third gets-2. - CJK characters survive on GitHub, so
## 安裝步驟becomes#安裝步驟. - Emoji and most symbols are removed entirely.
- Slug rules differ slightly between renderers, so guessing is unreliable.
Tip: When a jump link does nothing, stop guessing the slug. Open the rendered page, hover the heading, and copy the anchor from its own link icon. That takes five seconds and is right every time.
Linking to a heading in another document
Combine a path and a fragment. The path rules above still apply, and the fragment comes from that document's heading:
[Install the CLI](docs/setup.md#installing-dependencies)
[Rate limits](https://example.com/api/reference#rate-limits)
This is the backbone of navigation in multi-file documentation. Linking a section rather than a whole file is what actually helps the reader.
Image links, email, phone and the full picture
An image can be the clickable area of a link. Put the image syntax where the link text goes. This is how every build-status badge on GitHub works.
[](https://ci.example.com/builds/latest)
Read it inside out.  is the content, and the outer [...](destination) wraps it. The images reference covers alt text and sizing.
Email and phone links
Both use ordinary URL schemes:
<[email protected]>
[Email the team](mailto:[email protected]?subject=Docs%20feedback)
[+886 2 1234 5678](tel:+886212345678)
The angle-bracket form autolinks an address. On GitHub it also obfuscates the address in the HTML, as light spam protection. A tel: link dials on phones and does nothing on desktop, so keep the readable number as the link text and the digits-only international form in the URL.
Every link type at a glance
The table below covers all twelve forms, what each one is good for, and the renderer quirk to remember.
| Link type | Syntax | Best for | Renderer notes |
|---|---|---|---|
| Inline | [text](url) | Almost everything | Universal |
| Inline with title | [text](url "Title") | An extra hover hint | Universal; hidden on touch devices |
| Reference | [text][id] plus [id]: url | Repeated or very long URLs | Universal; IDs are case-insensitive |
| Collapsed reference | [text][] | When the text is the ID | Universal |
| Shortcut reference | [text] | Glossary-style docs | Universal, but fires on any bracketed phrase |
| Autolink | <https://example.com> | Showing the URL itself | Needs a full scheme |
| Bare URL | https://example.com | Chat and comments | GFM only; plain text in CommonMark |
| Anchor | [text](#heading-id) | Same-page navigation | ID rules vary by renderer |
| Cross-file anchor | [text](docs/setup.md#install) | Multi-file documentation | Site generators may rewrite the path |
<[email protected]> | Contact lines | GitHub obfuscates the address | |
| Phone | [0912 345 678](tel:+886912345678) | Mobile-first pages | Dials on phones, inert on desktop |
| Image link | [](url) | Badges and banners | Universal |
Awkward URLs, escaping, and opening in a new tab
Spaces in a URL
A space ends the destination, so [Report](my report.pdf) breaks. There are two fixes. Percent-encode the space, which is the portable option, or wrap the destination in angle brackets, which CommonMark and GitHub both support:
[Q3 report](my%20report.pdf)
[Q3 report](<my report.pdf>)
Parentheses in a URL
A closing parenthesis can end the link early. CommonMark allows balanced pairs, so a Wikipedia URL ending in _(disambiguation) usually survives on GitHub. An unbalanced one does not, and older renderers fail on both. Escape it with a backslash, or encode it as %28 and %29:
[Markdown](https://en.wikipedia.org/wiki/Markdown_%28disambiguation%29)
[Release notes](https://example.com/notes\(final\))
The same escape works for a literal square bracket in link text. Write \[ to show a bracket that should not start a link.
Opening a link in a new tab
Markdown has no syntax for this, by design. The format describes structure, not behaviour. If you genuinely need it, drop to raw HTML:
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Open the dashboard</a>
Always pair target="_blank" with rel="noopener noreferrer". Without it, the destination gets a scriptable handle back to your page. Many platforms strip raw HTML from Markdown anyway, and most site generators have a setting or plugin that adds the attribute to external links for you. Our Markdown versus HTML comparison maps the boundary between the two formats.
Common mistakes and their fixes
Five failures cover almost every link that will not render:
- Brackets the wrong way round, with the text in parentheses.
- A space between
]and(, which prints the brackets. - Full-width brackets from a Chinese or Japanese IME.
- An anchor copied from the heading text, capitals and punctuation included.
- An unencoded space in the URL, which truncates the destination.
Bracket order and the extra space
Text goes in square brackets, the URL in parentheses. Broken, then fixed:
(Markdown guide)[https://mdeditor.tw/markdown-guide]
[Markdown guide](https://mdeditor.tw/markdown-guide)
The space is fixed by deleting one character. Broken, then fixed:
[Markdown guide] (https://mdeditor.tw/markdown-guide)
[Markdown guide](https://mdeditor.tw/markdown-guide)
Full-width brackets from a Chinese IME
This is the failure that costs CJK writers the most time. With the input method set to full-width punctuation, typing brackets produces [] or () instead of ASCII [] and (). They look almost identical on screen, but the parser sees ordinary text and renders nothing. Broken, then fixed with ASCII punctuation:
[Markdown 指南](https://mdeditor.tw/markdown-guide)
[Markdown 指南](https://mdeditor.tw/markdown-guide)
Tip: Fix this once at the source. Switch the IME to half-width punctuation before writing Markdown; both the Chinese and Japanese input methods on macOS and Windows have that toggle. The same trap catches full-width # in headings and ` in code spans, so one setting saves you three separate debugging sessions.
Anchors and unencoded spaces
Capitals and punctuation do not survive slug generation. Broken, then fixed:
[Setup](#Setup Guide!)
[Setup](#setup-guide)
An unencoded space is the last one. Everything after the space is treated as a title or discarded, so the link points at a truncated address. Percent-encode it as shown above.
Debugging a link that misbehaves
Paste the line into the editor and watch the preview. It is nearly always one of these five.
The complete Markdown guide puts links in context, the cheat sheet keeps the syntax one glance away, and the sibling references for lists, tables and code blocks cover where links most often live.
Support data verified
Frequently Asked Questions
How do I make a Markdown link open in a new tab?
Markdown has no syntax for it. Use raw HTML: <a href="https://example.com" target="_blank" rel="noopener noreferrer">text</a>. Platforms that strip HTML will drop the whole tag, and most static site generators have a setting or plugin that adds the attribute to external links automatically.
Why does my anchor link not jump to the heading?
The fragment does not match the generated ID. IDs are lowercased, punctuation is stripped and spaces become hyphens, so ## API Key (v2) becomes #api-key-v2, and duplicate headings get a -1 suffix. The reliable method is to open the rendered page and copy the anchor from the heading's own link icon.
When should I use reference-style links?
When a URL repeats, when it is long enough to make the raw line unreadable, or when the file is reviewed as a diff and you want URL changes isolated at the bottom. For a single link in a comment or a short note, an inline link is simpler to follow.
Do bare URLs become clickable automatically?
Only in GitHub Flavored Markdown and similar dialects. Plain CommonMark and older renderers leave them as text. The portable options are angle brackets, <https://example.com>, or a full inline link with your own descriptive text.
Why do my links break when I type them in Chinese?
The input method is inserting full-width brackets, [](), instead of ASCII [](). They look nearly the same but the parser does not recognise them. Switch the IME to half-width or English punctuation before typing Markdown syntax and the problem disappears for headings and code spans too.
Keep learning
Try the Editor
Try the Editor