There is no attribute “target” – w3 validation error for HTML Strict

We commonly use target=”_blank” attribute in our source codes to make links open in new window. Quite usual practice right? but guess what, strict doctype don’t like it.

There is no attribute “target” – w3 validation error for HTML Strict

If you’ve set the doctype DTD to be html strict, it will give error on target attribute saying there is no attribute “target”.

So what’s the solution to it? yeah definitely, change the doctype from strict to transitional (or stop using target attribute!)

One more option is to remove the target attribute and set the links to open in new window via javascript, but anyway out of the scope of this post.

Coming back to the point, how to change the dtd to html transitional.

How to fix There is no attribute “target” – w3 validation error for HTML Strict

Simply, open your html source file (if you’re using theme of wordpress, goto header.php and find the dtd code on top) saying something like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

and change it to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Save your file and run the validator again.

Let me know if you have any trouble while fixing the there is no attribute “target” error while validating your html site.

Leave a Reply

Your email address will not be published.