I want to open a link in the same tab with html when clicking a word. Nevertheless, even if I've tried it using target="_self
" and not using any target, it only works with target="_blank"
, but, as you may know, this opens the link in another tab.
Code:
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body
{
min-width:360px;
}
a{
color:#009900;
text-decoration:none;
}
a:hover
{
text-decoration:underline;
}
p
{
font:0.8em sans-serif;
}
h1
{
font:1.5em sans-serif;
color:#fff;
background:#006600;
padding:5px
}
</style>
</head>
<body>
<h1>play</h1>
<p><a href="https://www.youtube.com" target="_blank">YT player</a></p>
</body>
</html>
Use _self in target attribute of anchor tag to Open link in same tab in HTML webpage.
You can make a HTML link open in a new tab by adding the target=”_blank” attribute. You should insert this after the link address.
html" target = "_self"> </a> Else, use Javascript: window. open('page. html', '_self'); Bye. :) target=_blank is used to open link in new tab, what if we remove target attribute, won't that help in html, and In JavaScript by default would be different like opening in new tab ..... that's why it is not working.
<a target="_self" href="https://www.youtube.com" >YT player</a>
Use _self
<a target="_self" href="https://www.youtube.com" >YT player</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With