Links
are called hyper or anchor links on web pages.
anchor links on a web page allow you to link to content on the same page or a different page
These support navigating to different sections/URLs of web resources.
Here is an example for writing anchor links using an HTML tag
<a href="about.html">About<a>
Mainly, It contains two parts - the first is the page name url, and the second name is the display text.
Markdown syntax links
Links
creates with the below syntax in markdown.
[Link text](linkurl)
Link text wrapped in square brackets([]) followed by link URL with parenthesis.
There are many types of links that can create in Markdown.
- Inline Links
- Relative Links
- mailto Links
- Reference Links
Inline or External Links in markdown
External
links are links pointing to an external domain.
Inline
links contain text displayed to the user enclosed in square brackets []
.
and link URL enclosed in parenthesis ()
.
Links Url is an absolute URL like domainname.extension.
[links text](Links Url)
Generated HTML is
<a href="#">links text</a>
Rendered text on browser
And output is links textRelative Links in markdown
relative
links are used for links within the same domain.
For example, relative URLs are /about
It contains without HTTP and website.com/about
[links text](relative Url)
example
[About Us](/about)
Generated HTML is
<a href="/about">About Us</a>
How to add link part of the same document in markdown.
Sometimes we want to navigate sections or parts of a document on the same webpage.
[go to heading](#heading)
On the webpage, You will have
<a name="heading">
My Heading
</a>
mailto links in markdown
mailto
links are used to include a link with an email address.
to add email address links with markdown markup,
Link contains mailto
with colon and email address
The syntax
[Contact Us](mailto:[email protected])
and output:
Reference Links
It link defines the link text with names. These names are referenced and mapped with the URL
It is reference links [emphasis tutorials][myexample]
[myexample]: /file/markdown-emphasis "markdown emphasis tutorials"
Output
It is reference links emphasis tutorials
Links with title
markup can also contain links with title text Add title text enclosed in double quotes in parents including link URL
Links title example [example link](URL "link title text")
Output Links title example example link
Create a link with target blank in markdown
There is no way to open a new window with standard markdown syntax.
You can use a simple anchor tag like this below
<a href="url" target="_blank">link</a>
Some implementations like kramdown to use below syntax
[link](url){:target="_blank"}