Live data from Hacker News

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

kyrylo.org

81–90 of 203 posts

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

#81
post #74
post #41

So basically It’s an “_blank” because it is.. Author’s description is, “because if it wasn’t _blank.. it wouldn’t open a new tab.” Reminds me of some university professors I had.

When I built "webapps" in the 90s, they were a collection of frames. You could just do everything as one page, but there were some neat things you could do by dividing the page up into frames + internet connections were not very good so if you had something you needed to update a lot, it was easier to make it it's own .html and server it in an iframe. Because you could "NameAFrameAnyThingYouWanTED" they made some mag…

This is exactly what I understood from the article. Your explanation didn't add anything extra.

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

#82
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...

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.

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

#84
post #44

> developers needed a way to explicitly tell the browser to open the link in a new tab, free of frame semantics First, it doesn't say why an underscore does that, because you could totally have underscores in frame names. My guess as others here is that the underscore prefix dates back from reserved names in C and C++. IIRC the reserved names also included "_self" (even if it was the default), "_parent" (to go up a l…

> IE was the most used browser back then, by a large proportion, and it didn't supports tabs at all.

Internet Explorer barely even existed back then, it certainly wasn’t the most used browser. That came later. No browser had tabs back in those days.

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

#85

Tangential, but I would really like frames to come back for incremental document updates, like LiveView/Hotwire/HTMX. You can just start working like that today with one of those libraries, but it would be so neat to have a common standard for describing an update to a targeted frame.

Agreed! There is a proposal for something like that in the WHATWG repo: https://github.com/whatwg/html/issues/8538

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

#86
post #81
post #74

Earlier quoted context omitted.

When I built "webapps" in the 90s, they were a collection of frames. You could just do everything as one page, but there were some neat things you could do by dividing the page up into frames + internet connections were not very good so if you had something you needed to update a lot, it was easier to make it it's own .html and server it in an iframe. Because you could "NameAFrameAnyThingYouWanTED" they made some mag…

This is exactly what I understood from the article. Your explanation didn't add anything extra.

I actually used the 1.0 version of Netscape Navigator, and did some web development on it back in the day.

Originally, _blank, _new, etc. weren’t special. A target ref to a name which wasn’t used would open a new window. If it was already used, it would take you to that open window.

People started using _whatever because just ‘blank’ would almost always cause a collision. Eventually it got standardized that it would always open a new blank window.

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

#87
post #36

Earlier quoted context omitted.

Yeah it’s not a great explanation. To me (and I’m of the era they’re describing so I used it a lot) it’s simply that _blank is a reserved keyword that means open the link in a new, unnamed window. Other reserved keywords for “target” are _self (default value), _parent, and _top. https://www.w3schools.com/TAgs/att_a_target.asp

But why was _name the naming syntax for reserved keywords, specifically?

Most other characters you would use aren’t valid HTML, and originally you could say things like target=foo (no quotes) and it would work.

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

#88
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...

I wouldn’t say it’s a “holdover”, it continues to be a common convention for marking internal or reserved use.

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

#89
post #53

Earlier quoted context omitted.

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.

Actually, frames were ugly, limited and not really ergonomic but they weren’t a wrong pattern. They solved a real problem of having parts of the page that changes and other parts that didn’t. It’s a shame they were deprecated without a modern replacement. An "include" mechanism (like what html provides) should have been proposed to replace this use case. The deprecation of frames forced dynamic websites (wether it is…

> Actually, frames were ugly, limited and not really ergonomic but they weren’t a wrong pattern.

They were. The most fundamental part of the WWW architecture is the URL. URLs are more important than even HTML or HTTP. Without addressability, the web doesn’t work.

Frames break URLs because you can visit a site that uses frames, navigate around the site, and the URL won’t change. You can’t link to the place you arrive at. Frames break addressability and this makes them go completely against the grain of the WWW. Flash and Java applets were fundamentally at odds with the WWW architecture as well for the same reason.

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

#90

Tangential, but I would really like frames to come back for incremental document updates, like LiveView/Hotwire/HTMX. You can just start working like that today with one of those libraries, but it would be so neat to have a common standard for describing an update to a targeted frame.

HTML has a bunch of good stuff in it that'd replace the need for so much heavy and slow and non-native-feeling javascript if that'd just been improved. Lots of it's now rarely used because it sucks, but there's no good reason it has to suck. It's like whole sections of the spec just got abandoned around 2005, but the need is still there.

The tag needs to make a comeback; I'm so tired of having to write my own JavaScript to get annoying flashy text.

In all seriousness, I'm not entirely sure why so many features in HTML are eschewed in favor of a slow JS mess. It doesn't feel like bolting on an entire relatively-slow programming language is going to make your code more organized than a relatively easy to use tag.

Post reply on HN