XHTML Invalid target="_blank" Alternative

The target attribute of the <a> element has now been deprecated and will not validate XHTML 1.0 strict, XHTML 1.1 nor any subsequent versions.

The target="_blank" attribute, used to open a link in a new window (most commonly in linking to external sites) has a nice elegant alternative using the ‘onclick’ attribute.

<a href="http://www.nostin.com" onclick="window.open(this.href); return false;">link to site</a>

If a visitor to the site has javascript turned off, the page will just load in the current window.

If you want to check a web pages validity, the W3C have provided this handy markup validation tool

Comments (0)
+ –