Friday 16 December 2011

target _blank xhtml strict compatible

How to: target _blank xhtml strict compatible


You maybe know that you can't validate as xhtml strict a page if you use

Code:

<a href="http://www.w3it.org" target="_blank">w3it.org</a>


the target attribute for the a element in xhtml strict can't be recognized as possible value: in fact the XHTML strict DTD do not include this attribute.
There is a way in any case to fix the problem and achieve the result, creating a link that will be opened on another browser Page or Tab ( like the target="_blank" do ). The following code reproduce the same effect as the above link where is used the attribute target, but it is XHTML STRICT compatible:

Code:

<a href="http://www.w3it.org" onclick="window.open(this.href,'_blank');return false;">w3it.org</a>

No comments:

Post a Comment