Live data from Hacker News

Why does target="_blank" have an underscore in front? (2024)

kyrylo.org

171–180 of 203 posts

Re: Why does target="_blank" have an underscore in front? (2024)

#171
post #18

I was expecting this post to explain why it's an underscore specifically, as opposed to a dollar sign, an asterisk, a caret, a tilde or some other special character. I can only assume it's a holdover of languages like C where the standard library has some reserved names that start with an underscore. https://devblogs.microsoft.com/oldnewthing/20230109-00/?p=10...

Making it a dollar sign would cause countless bugs for people who generate HTML using templating languages whose variables are indicated by dollar sign. From time to time, someone would add target="$blank" to a templates, forgetting that the $ must be escaped to be literal. They might have to resort to predefining a reserved variable called blank, whose value is "$blank". :) Similar reasoning applies to most other sp…

Your reason is unlikely to be a cause.

The _ comes from the W3C in 1995 well before JavaScript was commonly used for templating HTML.

Scripting has used $ for variables for a long time: I think the most relevant history line for $variable is PHP comes from Perl comes from shell scripts. I also remember finding $ ugly on Vax.

There were a huge variety of templating syntaxes for server side and HTML generation was virtually all server side in the 1900s.

Server side languages were very rarely JavaScript before Node in 2009.

JavaScript wasn't used much for HTML generation before Ajax. There were soon after many many client side templating syntaxes.

I'm guessing only Brendan Eich could say why $ was accepted for JavaScript variable names.

Timelines are hard because the foundations were compressed within a decade: JavaScript 1995, PHP 1996, DHTML 1997, Ajax early 2000s, jQuery 2006.

Syntaxes tend to be extremely path dependent, and every developer cribs from everything they use.

Re: Why does target="_blank" have an underscore in front? (2024)

#172

On this topic: Please NEVER use target=_blank. If the user wants a new window or tab, then they can open a new window or tab. There are so many websites where navigating around for a bit makes you end up with 5-6 tabs open, all with broken history, thanks to this mis-feature. _blank is evil and user hostile. Don't be evil and user hostile.

I hate this so much. There are a few extensions that try to limit the damage, but none of them work super well. There's no reason for target=_blank to exist.

Re: Why does target="_blank" have an underscore in front? (2024)

#173
post #33
post #8

My first "web app" used frames, it was good times. Some time later I used backbone.js, and while it was still good times, it did get a lot more complicated (e.g. having to manually disconnect and reconnect 'child' elements when the main element re-rendered so that they would retain their event handlers).

Ouffff, I haven't heard of backbone.js for a long time. Yeah, my first web also used frames and framesets, then I discovered iframes and it was a whole new world! I didn't need PHP to do includes. And when with JS I could adjust the size of the iframes dinamically, that was like magic.

my current job still uses it deep in some abstraction created ages ago...

Re: Why does target="_blank" have an underscore in front? (2024)

#174

Why did we move away from this model of web development? If I remember back that far, it seems like fairly soon after this was when the meta starting telling us that frames were bad, and using was bad, etc. It all honestly seemed a lot easier than what has come after.

Tables didn’t work very well with screen readers if memory serves me right. That and it produced a tag soup.

Ironically people moved to divs and spans, which when combined with the old box model issues, made the problem even worse.

The semantic web elements in HTML5 was an attempt to fix those issues.

Re: Why does target="_blank" have an underscore in front? (2024)

#175

I went digging in W3C archives to find relevant discussions. There are 4 reserved target names: _blank, _parent, _self, _top. - 1995 Sept https://web.archive.org/web/19990202141025/http://home.mcom.... Netscape Navigator 2.0a2 release notes including rollout of TARGET. - 1995 Sept https://lists.w3.org/Archives/Public/www-html/1995Sep/0034.h... First definition of them; spec text provided by "the Netscape Navigator ma…

There probably was no discussion about it. Back then you didn't have tens of managers looking to add their input to a project, so if you came up with something, you could just demo it, and unless someone had a very specific reason to reject it, nobody would. I'm not saying this is the answer, but it very well could be that whoever wrote the function that handles this decided on an underscore and nobody ever even ques…

and really this should be the path: define a new convention, then standardized after - if it's needed (spoiler: probably not going to need it). This is definitely not perfect; it's incredibly painful to retrofit standards, but I'm not convinced it's less work than creating a bunch of standards no one needs.

Re: Why does target="_blank" have an underscore in front? (2024)

#176

I went digging in W3C archives to find relevant discussions. There are 4 reserved target names: _blank, _parent, _self, _top. - 1995 Sept https://web.archive.org/web/19990202141025/http://home.mcom.... Netscape Navigator 2.0a2 release notes including rollout of TARGET. - 1995 Sept https://lists.w3.org/Archives/Public/www-html/1995Sep/0034.h... First definition of them; spec text provided by "the Netscape Navigator ma…

There probably was no discussion about it. Back then you didn't have tens of managers looking to add their input to a project, so if you came up with something, you could just demo it, and unless someone had a very specific reason to reject it, nobody would. I'm not saying this is the answer, but it very well could be that whoever wrote the function that handles this decided on an underscore and nobody ever even ques…

There was a recent post about asking for “no”, in other words defaulting to yes unless there’s an objection before a deadline. I like that model.

Re: Why does target="_blank" have an underscore in front? (2024)

#177

I think it's funny that Mozilla says not to use frames anymore, they work just fine on modern browsers...

You mean [the mdn docs]( https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fr... )? Looks like classic deprecation to me: they'll still 'work', you just shouldn't use them. In the same way that tables-for-layout still 'works', but you shouldn't actually do that.

Of note: is marked obsolete, not deprecated, in the current HTML standard (aka HTML5): https://html.spec.whatwg.org/dev/obsolete.html#non-conformin...

Re: Why does target="_blank" have an underscore in front? (2024)

#178
post #157

Earlier quoted context omitted.

As another borrowed convention, JS developers of yore (and likely some today still) used an _ prefix to denote “private” function/methods. Quotes as it’s just a convention - today JS supports # for actual private members in class syntax.

Another weird case: In Google's server-side JS environment Apps Script, function names that end with _ are treated as private functions that cannot be called directly by the user or enumerated. 1. https://developers.google.com/apps-script/guides/html/commun...

In the Python world I was in, trailing underscores is used to work around the ban on reserved words. The language grabs some of the best names for itself!

So a variable that really ought to be named `class` you name `class_`.

Re: Why does target="_blank" have an underscore in front? (2024)

#179
post #83

> P.S. Don’t use . It’s deprecated in HTML5 Tell that to the enterprise email scanning software my Fortune 500 company uses

Of note: is marked obsolete, not deprecated, in the current HTML standard (aka HTML5): https://html.spec.whatwg.org/dev/obsolete.html#non-conformin...

Re: Why does target="_blank" have an underscore in front? (2024)

#180

Earlier quoted context omitted.

There probably was no discussion about it. Back then you didn't have tens of managers looking to add their input to a project, so if you came up with something, you could just demo it, and unless someone had a very specific reason to reject it, nobody would. I'm not saying this is the answer, but it very well could be that whoever wrote the function that handles this decided on an underscore and nobody ever even ques…

There was a recent post about asking for “no”, in other words defaulting to yes unless there’s an objection before a deadline. I like that model.

I am making extensive use of deadlined passive approval for decision I consider non-contentious. For everything else I set up meetings. I don't believe in async review of contentious decisions.
Post reply on HN