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 of 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
is created with the below syntax in Markdown.
[Link text](linkurl)
Link text wrapped in square brackets([]) followed by link URL with parenthesis.
Many types of links can be created 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 parentheses ()
.
Links Url is an absolute URL like domainname. Extension.
[links text](Links Url)
Generated HTML is
<a href="#">links text</a>
And the output is [links text](#)
Relative 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 a 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](URL "link title text")
Create a link with a target blank in the 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
use the below syntax
[link](url){:target="_blank"}