Opening a link in a new window under XHTML 1.1

In HTML 4, you can open a link in a new window using the <code>target="_blank"</code> attribute in your anchor element, in XHTML 1.0 strict and XHTML 1.1, this attribute is not valid. So how do you get this effect using valid XHTML syntax? Javascript!



<code><a href="http://www.burpee.com/" onclick="window.open(this.href); return false;">Burpee</a></code>



This method has the benefit of working on browsers that do not have Javascript enabled or do not have the capability to open a new window.



Try it: <a href="http://www.burpee.com/">Burpee</a>



<strong>Note:</strong> You should use this technique sparingly. In general, you should design your site so that the user is in control. If they want to open a link in a new window, they already have the ability to do that.