Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why the target property in link has an underscore?

I have been coding for many years and only at this moment I just realized that the property target from the element <a> requires all their values start with an underscore (a lot of us know that), but I don't know why? I mean from the top of my head I don't remember another value which required to start with an underscore except for that.

Does anybody know what is the reason behind this implementation, and what other values start with an underscore?

This is just a historical question, but it would be cool to know why everybody uses this convention which I think is only applied to target.

target - (_blank, _self _parent, _top)

like image 276
ncubica Avatar asked Mar 09 '14 23:03

ncubica


People also ask

Why does target blank have a underscore?

_blank Opens the linked document in a new window or tab. _self Opens the linked document in the same frame as it was clicked (this is default)

What is target _blank in a href?

a target=”_blank” Open in New Browser Tab (or Window) The target attribute specifies where the linked document will open when the link is clicked. The default is the current window. If target="_blank" , the linked document will open in a new tab or (on older browsers) a new window.

What does the target _blank attribute do in the HTML a tag?

A target attribute with the value of “_blank” opens the linked document in a new window or tab. A target attribute with the value of “_self” opens the linked document in the same frame as it was clicked (this is the default and usually does not need to be specified).

When should the target _blank attribute not be used in a hyperlink?

One such case is a website that deals with sensitive customer information. If a health or finance-related website uses _blank for links to private information, it may cause the site visitor to spawn multiple web pages with sensitive information. They may unknowingly leave these windows open unintentionally.


2 Answers

It's not a convention; it's specified in the standard (4.0, 5) that the four reserved names for the target attribute are _blank, _self, _parent, and _top. You can have other target values, but they would be custom names which must start with a letter. Having the reserved ones start with an otherwise illegal value distinguishes them from custom named targets.

like image 181
tvanfosson Avatar answered Oct 24 '22 14:10

tvanfosson


  1. The target value can be the name of a frame.
  2. The frame could have the name "blank".
  3. Conflict!

There needs to be a way to disambiguate: Is this the name of a frame or is this the name of a reserved browsing context?

So let’s prefix any reserved name with a specific character and disallow this character for use as first character in other values.

like image 43
unor Avatar answered Oct 24 '22 16:10

unor