Posted By

neal_grosskopf on 02/25/08


Tagged

html xhtml strict validation


Versions (?)

Who likes this?

5 people have marked this snippet as a favorite

neal_grosskopf
SmpleJohn
brent-man
basicmagic
Bonky


How To Use target="_blank" Correctly In XHTML & HTML Strict


 / Published in: HTML
 

URL: http://www.nealgrosskopf.com/tech/thread.asp?pid=2

If you've ever used a strict doctype and used the target attribute on links you'll notice that it doesn't validate. Here is an easy solution.

  1. <a href="http://www.nealgrosskopf.com" onclick="window.open(this.href);return false;">Link</a>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: wbowers on February 28, 2008

It doesn't validate for a reason - because opening links in new windows is bad for accessibility.

Posted By: neal_grosskopf on April 7, 2008

At some point, developers need the ability to do it at least. The W3C depreciated target="_blank" because they felt it was more of a behavior and would best be accomplished using javascript.

Posted By: schkayalogy on May 17, 2009

Neat workaround using JavaScript so you don't have to type the 'onclick' event on every single anchor @ http://www.theghostcoder.com/2009/05/working-around-xhtml-strict-target-support/

You need to login to post a comment.