Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a link in the same tab with html

Tags:

html

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>
like image 416
pepito Avatar asked Jul 03 '17 11:07

pepito


People also ask

How do I make a link open in the same page in HTML?

Use _self in target attribute of anchor tag to Open link in same tab in HTML webpage.

How can you open a link in a new tab browser window in HTML?

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.

How do I open an HREF in the same window?

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.


1 Answers

<a target="_self" href="https://www.youtube.com" >YT player</a>

Use _self

<a target="_self" href="https://www.youtube.com" >YT player</a>
like image 116
O.Rares Avatar answered Sep 19 '22 22:09

O.Rares