This exercise uses the `_blank` value to open pages in new tabs. Does the `target` attribute have other values?


#1

Question

This exercise uses the _blank value to open pages in new tabs. Does the target attribute have other values?

Answer

Yes, there are 4 different values the target attribute can have: _self, _blank, _parent, or _top. These values specify a browsing context or the environment in which the browser will display a document. To learn about each of these values, check out Mozilla docs!


FAQ: Learn HTML Elements - Common HTML Elements - Opening Links in a New Window
#2

doesnt it also include grandparents?


#3

…and grandchildren?


#4

…and grandgrandparents


#5

Is it mandatory that the target attribute be written after the href attribute or it doesn’t matter, it functions the same either way?


#6

I’m pretty sure that you don’t have to include the target attribute, it’s just good practice to make determinations about how the browser will open a link you insert. If you don’t specify it, I’m sure browsers have some kind of default link-opening behavior.


#7

It is not mandatory, but like the article stated that you may want the person to come back to your page. Without the target attribute the link will open the new page in your same tab. If the person closes the tab they also close your page. Opening it in a new tab will make sure they come back to your page after they close out the other tab.


#8

What happens when you change the value of the attribute to _self, _parent, or _top? Tried it out in the index.html doc for brown bears but wasn’t able to see a visible difference.