In this short post, find out how to open a markdown link in a new tab.
When using markdown to create your blog or any web page using a markdown parser we might want to open the link in our webpage in a new tab.
In markdown, we can create a link using the markdown syntax like this
[Link to google](https://google.com)
This will create <a>
tag link in our parsed HTML output link this
<a href="https://google.com" >Link to google</a>
When we click this link, it will open google in the same tab.
So how can we open the link in a new tab in markdown ?
To open a link in a new tab in our browser is very simple, we just have to use the target
attribute in our <a>
tag.
Even though there is no native way to add any attributes in our markdown syntax, markdown allows us to use plain HTML tags whenever needed.
So, we can use write the <a>
in our markdown document and set target='_blank'
attribute.
<a href="https://google.com" target="_blank">Link to google</a>
This code will create the link in our webpage which when clicked will open the link in a new tab in our browser.
Related Articles:
How to write superscript and subscript in markdown
How to center align an image in markdown
How to do text highlight in markdown
How to change image size in markdown in GitHub
How to make horizontal line in markdown