Question
Markdown Links That Open in a New Tab: target="_blank" Explained
Question
Is there a way to create a Markdown link that opens in a new browser window or tab? If standard Markdown does not support this, what syntax should I use when adding the feature to a Markdown compiler? I believe this behavior should be available as an option.
Short Answer
Standard Markdown link syntax does not define a way to add target="_blank". You will learn why this is intentional, how embedded HTML can solve the problem when supported, and how to design a compiler extension without making documents unnecessarily hard to move between tools.
Concept
Markdown is a lightweight markup language designed to describe document structure with simple, portable syntax. A normal Markdown link describes only two essential pieces of information:
[Link text](https://example.com)
It says, “display this text as a link to this URL.” It does not specify browser behavior such as whether the link opens in the current tab, a new tab, or a separate window.
The HTML attribute target="_blank" controls that browser behavior:
<a href="https://example.com" target="_blank">Link text</a>
Standard Markdown has no universal syntax for adding arbitrary HTML attributes to links. This keeps Markdown simple, but it also means that Markdown written for one renderer may not support renderer-specific features in another.
Many Markdown renderers allow inline HTML. When they do, you can write an HTML anchor directly. Whether it works depends on the renderer and its security configuration: some systems deliberately strip HTML or remove attributes such as target.
Also, _blank means “open in a new browsing context.” In modern browsers this is usually a new tab, but the user’s browser settings ultimately decide how it appears.
Mental Model
Think of standard Markdown as a shipping label. It states the destination of a package:
[Documentation](https://docs.example.com)
The label does not dictate the driver’s route or which truck door is used. Likewise, Markdown gives the link destination but leaves browser navigation behavior to the browser or website.
HTML is a more detailed shipping form. It can include extra instructions, such as target="_blank". A Markdown compiler extension is like creating your company’s own extra label field: useful in your environment, but not guaranteed to be understood by another shipping company.
Syntax and Examples
A standard Markdown link uses this syntax:
[Visible link text](https://example.com)
For example:
Read the [project documentation](https://docs.example.com).
Standard Markdown does not provide an official equivalent of this HTML:
<a href="https://docs.example.com" target="_blank">project documentation</a>
If your Markdown processor permits inline HTML, use an HTML anchor when a new tab is genuinely needed:
Read the <a href="https://docs.example.com" target="_blank" rel="noopener noreferrer">project documentation</a>.
rel="noopener noreferrer" is commonly added to links that use target="_blank":
noopenerprevents the new page from controlling the page that opened it throughwindow.opener.noreferreradditionally avoids sending the referring page URL in many browser situations.
If you are creating a Markdown extension, choose a syntax that is explicit and easy to parse. For example:
[project documentation](https://docs.example.com){target="_blank"}
This attribute-list style is used by some Markdown ecosystems, but it is not part of standard Markdown. Your compiler would need to recognize it and render safe HTML.
Step by Step Execution
Consider this source:
Visit <a href="https://example.com" target="_blank" rel="noopener noreferrer">Example</a>.
A renderer that allows inline HTML processes it as follows:
- It reads the Markdown text.
- It recognizes the
<a ...>element as inline HTML rather than ordinary text. - It keeps the
hrefvalue as the link destination. - It keeps
target="_blank", which asks the browser to use a new browsing context when the link is activated. - It keeps
rel="noopener noreferrer"as a safety-related relationship setting. - The browser displays Example as a link.
- When the user activates the link, the browser generally opens
https://example.comin a new tab.
Now compare a renderer configured to escape HTML. It may output the literal characters <a href=...> as text, or sanitize the attributes. In that renderer, the same source will not behave as a new-tab link.
Real World Use Cases
Opening a link in a new tab is sometimes useful, especially when leaving the current page would interrupt work:
- Documentation portals: Link to an external API reference while keeping the current guide open.
- Admin dashboards: Open a customer’s public profile or a third-party payment page without losing the current record.
- Long forms: Let users review terms, policies, or help pages without navigating away from unsaved form input.
- Markdown-generated reports: Link to supporting evidence or external monitoring pages.
- Static sites: Mark selected external resources as new-tab links through a site-wide renderer rule.
Do not apply _blank to every link automatically. Opening new tabs unexpectedly can be disorienting, particularly for keyboard and assistive-technology users. Internal navigation normally belongs in the same tab.
Real Codebase Usage
In production applications, developers usually avoid putting target="_blank" throughout raw Markdown by hand. Common approaches include:
- Allow HTML selectively: A trusted documentation repository may permit HTML anchors in Markdown.
- Sanitize untrusted Markdown: If users can submit Markdown, sanitize the generated HTML and allow only a carefully chosen set of tags and attributes.
- Add a renderer extension: Support attribute-list syntax such as
{target="_blank"}and transform it into HTML during rendering. - Apply a site-wide external-link policy: After rendering, identify external links and add
target="_blank"andrel="noopener noreferrer"according to a documented rule. - Use reusable components: In MDX or component-based documentation systems, provide an
ExternalLinkcomponent so the behavior is consistent.
When implementing a compiler feature, validate attributes rather than passing arbitrary attribute text directly into generated HTML. A small allowlist such as target, rel, class, and id is much safer than accepting every possible attribute.
Common Mistakes
Assuming this is standard Markdown
This is not defined by standard Markdown:
[Example](https://example.com){target="_blank"}
Some renderers support it, but others may display {target="_blank"} as ordinary text. Document it as an extension and provide a fallback expectation.
Forgetting that inline HTML may be disabled
<a href="https://example.com" target="_blank">Example</a>
This works only if the Markdown renderer allows the relevant HTML. Test the actual compiler and its production configuration.
Using _blank without rel="noopener"
Less safe:
<a href="https://example.com" target="_blank">Example</a>
Prefer:
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Example</a>
Treating “new tab” as guaranteed
target="_blank" requests a new browsing context. A browser, browser extension, popup setting, or user preference may determine whether that becomes a tab or window.
Opening every link in a new tab
This removes the user’s control over navigation and can make browsing harder. Reserve it for links where preserving the current page is useful.
Allowing arbitrary raw HTML from untrusted users
Raw HTML can create security problems if it is not sanitized. For user-provided content, use a trusted sanitizer and an attribute allowlist.
Comparisons
| Approach | Example | Standard Markdown? | Best use |
|---|---|---|---|
| Normal Markdown link | [Docs](https://example.com) | Yes | Most links |
| Inline HTML link | <a href="..." target="_blank">Docs</a> | HTML is not required by every Markdown implementation | Trusted content where HTML is allowed |
| Attribute-list extension | [Docs](https://example.com){target="_blank"} | No | A controlled compiler or documentation stack |
| Renderer-wide rule | Automatically modify external links | No source syntax needed | A site with a consistent external-link policy |
target="_blank" versus no target:
| Behavior | No target | target="_blank" |
|---|---|---|
| Navigation location | Current browsing context | New browsing context, usually a tab |
| Best for | Normal site navigation | Selected external or reference links |
Recommended rel | Not needed specifically for this purpose | noopener noreferrer is commonly used |
Cheat Sheet
# Standard, portable Markdown link
[Label](https://example.com)
# HTML link when your renderer allows inline HTML
<a href="https://example.com" target="_blank" rel="noopener noreferrer">Label</a>
# Possible compiler extension; not standard Markdown
[Label](https://example.com){target="_blank"}
- Standard Markdown has no official
target="_blank"syntax. _blankusually opens a new tab, but the browser controls the final behavior.- Use
rel="noopener noreferrer"with_blankfor external links. - Check whether your renderer allows inline HTML.
- Treat attribute-list syntax as a documented, non-portable extension.
- Do not force every link to open in a new tab.
FAQ
Can Markdown links open in a new tab?
Not with standard Markdown syntax alone. Use inline HTML if your renderer permits it, or use a renderer-specific extension.
What is the Markdown syntax for target="_blank"?
There is no universal standard syntax. Some tools support attribute lists, for example [Link](url){target="_blank"}, but that requires explicit renderer support.
Does <a target="_blank"> work inside Markdown?
Often, yes. It works when the Markdown engine preserves inline HTML and does not sanitize away the target attribute.
Why should I add rel="noopener noreferrer"?
It is a common safety measure for links opened with _blank. noopener prevents the opened page from accessing the opener through window.opener; noreferrer can also suppress referrer information.
Will target="_blank" always open a new browser tab?
No. It requests a new browsing context. Browsers and user preferences decide whether that is shown as a tab or window.
Should all external Markdown links use _blank?
Usually no. Use it only when keeping the current page open clearly benefits the user.
How should a Markdown compiler support this feature?
Define a clear extension syntax, parse only supported attributes, escape generated HTML correctly, and document that the syntax is not portable standard Markdown.
Mini Project
Description
Create a short Markdown-based resources page that uses ordinary Markdown for internal navigation and an HTML anchor for an external reference that should open separately. This demonstrates the difference between portable Markdown syntax and renderer-dependent inline HTML.
Goal
Write a resources page with one normal Markdown link and one safe new-tab external link.
Requirements
Use a standard Markdown link for an internal page.
Keep learning
Related questions
Add a Favicon to a Static HTML Page
Learn how to add a favicon to static HTML pages, use correct paths and icon formats, and troubleshoot browser caching and local-file issues.
Allow Only Numeric Input (0-9) in HTML Input Using jQuery
Learn how to allow only digits 0-9 in an HTML input using jQuery, with examples, validation tips, common mistakes, and best practices.
Apply CSS !important with jQuery .css()
Learn why jQuery .css() cannot set !important and how to use CSSStyleDeclaration.setProperty() to apply inline important styles safely.