So i learned that the target attribute has four different values.The question is

So i learned that the target attribute has four different values.But when linking a hyperlink i used a random value(I JUST USED A RANDOM NAME) for the target attribute and it still worked.HOW?
I am using repl to practice


Can you paste an example of the code you’re talking about? (Be sure to format it with the </> button).

1 Like
<a href="" target="inkit">inkit</a>
As you can see i changed the value of the target attribute to inkit.But it still worked correctly and opened a new tab

html is incredible error resistant, thankfully. So even if you make a mistake as developer, you might get away with it.

In this specific scenario its safe to assume that the target value is not recognized, so the default value (_self) is used instead

1 Like

This is normal behavior. What you did was use a custom “framename” for the target attribute. An important part of what you said was that the link opened in a new tab. More links from your page with the same custom target would replace that tab if it was still open. This is very different behavior than using “_blank”, which opens up a new tab every time, or “_self” which would replace the page you clicked the link on.

Here’s a demonstration. The first set of links use the same custom framename for the target. Notice that they all use the same tab. Clicks of the second set of links containing “_blank” always open a new tab.

In case you want to play with it:

<!DOCTYPE html>

<h2>Link with target attribute set to a custom framename</h2>
<p>The first time one of these links are clicked, a new tab will be opened. The next time a link is clicked with the same target, that tab's URL will be updated. A new tab will not be opened if one was opened with the same target name already.</p>
  <li><a href="" target="customFramename">Codecademy</a></li>
  <li><a href="" target="customFramename">Adobe</a></li>
  <li><a href="" target="customFramename">Google</a></li>

<hr />

<h2>Link with target attribute set to '_blank'</h2>
<p>Every click will result in a new tab</p>
  <li><a href="" target="_blank">Codecademy</a></li>
  <li><a href="" target="_blank">Adobe</a></li>
  <li><a href="" target="_blank">Google</a></li>

1 Like

thank you,
this was super helpful.
what is the custom framename about though?

Glad it helped.

I used the term ‘framename’ because that’s how w3schools referred to it. I can’t give you a full history, but a long time ago browsers didn’t have tabs. There used to be a lot more actual popup windows and using iframes on regular sites was more common as well. That target attribute helped a lot. I assume that’s why it was referred to as “framename” on w3schools.

1 Like