'HTML link not going to external site
I have been running a localhost website with react.js while I am building a website and when I am trying to link to an external site (e.g. youtube) it ends up going to a link like this:
http://localhost:3000/www.youtube.com
while I am trying to go to:
I am using this to get my link:
<a href='youtube.com' target='_blank' rel='noreferrer'>YouTube</a>
Solution 1:[1]
Try this:
<a href='https://youtube.com' target='_blank' rel='noreferrer'>YouTube</a>
Solution 2:[2]
It's easy to use HTML to open a link in a new tab. You just need an anchor () element with three important attributes:
- The
hrefattribute set to the URL of the page you want to link to. - The
targetattribute set to_blank, which tells the browser to open the link in a new tab/window, depending on the browser's settings. - The
relattribute set tonoreferrer noopenerto prevent possible malicious attacks from the pages you link to
try using this
<a href="https://www.youtube.com/" target="_blank" rel="noopener noreferrer">youtube</a>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | New Programmer |
| Solution 2 | madaraUchiha |
