Story Details

  • Why does target="_blank" have an underscore in front?

    Posted: 2025-02-21 14:07:17

    The underscore in target="_blank" is a relic of older HTML versions where custom target names were conventionally prefixed with an underscore to distinguish them from predefined targets like _top, _self, _parent, and _blank. While underscores are no longer technically required for custom target names in modern HTML, the convention persists, especially with _blank, due to its widespread historical use. Essentially, the underscore was originally a way to signal a developer-defined target, separating it from the reserved target names built into the HTML specification.

    Summary of Comments ( 121 )
    https://news.ycombinator.com/item?id=43127577

    Hacker News users discussed the historical context of the underscore in target="_blank", attributing it to the legacy of SGML and HTML's early evolution. Some pointed out that the underscore was used as an escape character for non-standard attributes, allowing developers to introduce custom attributes without breaking the existing parser. This was especially important during the transition from SGML to HTML, as browsers were still evolving. The underscore acted as a signal that this was an extension, potentially browser-specific, and not part of the official standard at the time. Others questioned the current necessity of the underscore and whether modern HTML specifications still require it, suggesting it's primarily a historical artifact. A few comments also touched upon the security implications of target="_blank" without rel="noopener", a common topic often paired with discussions about this attribute.