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

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!

58 Likes

3 posts were merged into an existing topic: Do attributes need to be in a specific order?

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.

19 Likes

This is a late reply, but to clarify, the only target attribute value that has any effect in a single browser window is _blank, which refers to a new tab or window. These are legacy attributes that apply to frameset, a very uncommon thing in today’s era now that we have CSS. Frames predated CSS.

Also of note, attributes have no order. They can be written in any order, though usually we like to see the id and class attributes out front, and in that order. That’s just for reading, though. The browser makes no distinction of ordering or attributes.

122 Likes

is this supposed to open a new window, or just open a new tab on my browser?

2 Likes

That depends upon how your browser is set. Out the box most browsers default to a new tab.

17 Likes

I am enjoying so much just for reading the top questions below each exercise… that’s really awesome! : :+1:

89 Likes

you have to make a connection with the attirbute and the class because the selector make a visible page

14 Likes

what is difference between tab and window in a browser?

1 Like

Very little. Tabs permit multiple windows in a single browser shell or frame, but each is a separate browser, all the same. The cannot even speak to each other.

In the early days there were no tabs, only new windows. I don’t even remember who created tabs first, NetScape or Mozilla, or the emerging Firefox. Seems they were around when Chrome appeared on the scene.

22 Likes

thank you for clarifying

Yeah totally, I could have specified better. That’s essentially what I meant by it being good practice to make a preferred determination. After all, many links in a given site are just more internal links within the same site, which is the use case I happened to have in mind when I wrote my comment. Absolutely, it is better for user retention to use targeting and have any external links opening in a new tab/window. I just meant to communicate that it’s not like one has to include the target attribute in order to have a link work at all, since it’ll work one way or another without it.

4 Likes

There are 4 different values the target attribute can have: _self, _blank, _parent, or _top

I was able to replicate and understand blank and self.

But Parent and top was behaving the same way as self.
what is the use of parent and top values for target attribute

html - Difference between _self, _top, and _parent in the anchor tag target attribute - Stack Overflow

4 Likes

Ctr+n creates a new window
Ctr+t creates a new tab
See for yourself

8 Likes

what is Mozilla docs?

Mozilla docs is the Mozilla Developer Network (MDN) and an official source of reliable documentation for HTML, CSS, JavaScript, and other languages related to web development. Mozilla is the organization that gave us the Firefox browser. Their docs are closely connected to the World Wide Web Consortium, (W3C), the organization that gives vendors recommendations and specifications for the Living Standard implemented in most or all web browsers.

10 Likes

thanks for answer … and I hope you have a good day.

1 Like

Dear all readers I have a question related to target attribute is target attribute help in SEO as user will direct to new website or reduce the traffic on our website ?