Why does target="_blank" have an underscore in front?
58 comments
·February 21, 2025n_plus_1_acc
The answer is a little unsatisfying to me. It says that "blank" ca be a frame name, but doesn't say why "_blank" can't be.
tomhoward
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.
0x0
Also worth noting that "_new" is NOT a reserved keyword, but it is sometimes mistakenly used instead of "_blank". Which can lead to funny behavior if you are visiting 2 or more sites making this mistake, as the links could then start opening in windows that were initially opened by the other site. Or least that's how it was back in the days of popup windows, before tabs and popup blockers became the norm.
stickynotememo
But why was _name the naming syntax for reserved keywords, specifically?
beejiu
I suspect, when the specification was created, "_" was already popular for private/reserved members in many programming languages. In C++, for instance, you can only start an identifier with a letter or an underscore. So it seems like a natural, intuitive choice. Whether anyone can find any corroborating evidence would be interesting.
Maken
In other answer they link to the original specification [1], and it says that names must start with a letter, so anything preceded by "_" cannot be a frame name.
dcminter
I'm guessing it was possible before the window-opening behaviour came in (unless it was always there from the genesis of frameset), but it was assumed that the underscore prefixed version would be less likely to conflict with existing code than without.
I'd be interested to hear either a citation proving or disproving that guess though.
bilekas
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.
systems_glitch
"I dunno...is magic" (engineering Calculus II GTA, Virginia Tech, 2006)
p4bl0
> 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 level in the frame hierarchy) and "_top" to replace the whole page.
Second, at the time it was clearly not "open the link in a new tab" but rather in a "new window". IE was the most used browser back then, by a large proportion, and it didn't supports tabs at all.
systems_glitch
Probably the most likely explanation, given so many things do inherit idiosyncrasies from C. I'd always assumed it was from Perl, given its heavy use in CGI back then -- like $_ being the default var. But that would probably also eventually inherit from C :P
lifthrasiir
Shower thought: `<a href="..." target="_mobile">` should transfer a link in a desktop into my phone. Same goes for `target="_desktop"` but in the opposite direction.
SahAssar
Yay, that would be awesome for cross-device tracking! Also don't forget about _tablet, _phablet, _tv, _laptop, _watch, _work_laptop, _smart_speaker, _ereader, etc.
staz
Should it really be up to the Website designer to decide?
On Firefox I have the "Send Link to Device" context action that allow me to open a link on my Phone or Desktop.
berkes
I would imagine that it'd be best done with the "share" API that already exists.
A website designer then might say "share this url on click" and the browser takes over and/or defers to the OS.
Now, the share() [https://developer.mozilla.org/en-US/docs/Web/API/Navigator/s...] falls short in passing along context for login (e.g. cookies) so I'd imagine that this would either be part of the browser, or something the share() api could extend on, though I'd be unconfortable about the security implications of the latter.
The share() also falls short on desktop in my experience. AFAIK, firefox (on linux?) doesn't even have the share() API available.
The browser now already registers itself as a target to share web urls. It does this already (on my mobile devices at least) as "Open URL in Firefox" for example.
It should and could also add a target to share web urls, but call it "Send to device". Firefox for Android used to have this and it was awesome. But mozilla somehow dropped it. (There was a long thread on a bug report about exactly this, but I cannot find it).
Also, when I choose that option, it'd not just send the url along, but could also send any cookies or even localstorage and other data along. That way I'd be logged in.
That last part would be part of the "send to " feature, in Firefox called "firefox sync" and possibly be configurable from there to opt out of sending session or other data along.
Point is: there's no need for extra "target=" hackery, we already have all the tech in place to send links to devices. Instead, we'd have to convince browser builders to improve this tech and the UX of it.
tossandthrow
In my product we have a photo app and for normal people it is just easier to have the transferred to the phone than to use a desktop computer (without a camera) to grab a picture.
We use QR codes to transfer the user - a solution would need to be as simple as that (Ie. not requiring the user to be logged in on the same browser or other shenanigans).
The current solution is a hasle, but works well - I can't envision how a target="_mobile" should solve this? Especially since you need to transfer authentication also.
Asmod4n
On windows you can “link” your phone to your windows account, or log into your Microsoft account in edge on mobile. That could solve the login part somehow.
woodpanel
Sounds like a new product idea for services a la "login via apple-id/windows/google/...". Name it something like "send session to..."
graemep
KDE Connect does that on Linux and Android across browsers.
6510
<a target="_car"></a> <a target="_shower"></a> <a target="_doorbel"></a>
niek_pas
You read HN in the shower?
thih9
> SHOWER THOUGHT definition: a sudden idea that occurs to a person during an unconnected mundane activity
https://www.collinsdictionary.com/dictionary/english/shower-...
ramon156
Its a tongue-in-cheek comment
https://www.collinsdictionary.com/dictionary/english/tongue-...
(Not mocking, I just really liked the explanation and it happened to be the same site)
shreddit
That IP rating for my phone got be be useful for something
sangeeth96
Who doesn't?
AndrewOMartin
By only reading HN in the shower I limit the time wasted on browsing HN to a couple of hours a day.
advincze
It's crappy design. Instead of using a separate property for different functionality like target-new-window=true or sth. They wanted to be clever. I think this is misinterpreting Simplicuty by thinking that an additional property is complicating things
Cthulhu_
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).
101008
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.
dugmartin
I'm guessing it is because the developer at Netscape that added frame support thought about it for 5 seconds and came up with the name. Maybe if Lou Montulli sees this he would know?
nubinetwork
I think it's funny that Mozilla says not to use frames anymore, they work just fine on modern browsers...
oneeyedpigeon
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.
pjerem
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 client or server side) on everyone and i feel like it is in part responsible of why people stopped to handcraft websites.
zaxomi
>> It’s a shame they were deprecated without a modern replacement.
Isn't iframe the replacement? iframe is not deprecated.
bicsi
Wait, so frameset is basically htmx?
aryonoco
Minor nitpick: browsers used _blank as a special directive to open the link in a new “window”, not a tab. Browsers didn’t have tabs back then, well other than Opera 4.x which was a paid software which never cracked 3% marketshare.
kyrylo
Author here — thank you! You're absolutely right, and I've corrected it!
icedchai
Because back in the mid 90's, there was Netscape...
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...