XHTML Valid Syntax for target="_blank"

New Year 2013 Greetings to all of you!

Today, I’ll try to teach you that how could you get the target=”_blank” right according to the XHTML Syntax and having no parsing errors.

So, lets begin with it…

While coding for a website or blog template we may like to open up a link with attribute in a New Window / Tab.

The following command might be useful for that:

But if we are using XHTML 1.0 Transitional, or XHTML 1.0 Strict or some other XHTML versions, it will show a syntax error.

This was initially a very big problem for me. Finally, I found up two solution to the problem. One JavaScript and one jQuery solution.

JavaScript Solution:


You can apply an onClick event on a tag. See the following code:

Add this code between and tag.

Add this where you want your target=”_blank” link placed.

I hope this solution works for you. Tell me if it doesn’t.

jQuery Solution:


jQuery .attr could also be used to insert target=“_blank” inside an element.

Add this code to head section of your page:


Add this where you want your target=“_blank” link placed.

And this is the best solution I’ve found to this problem.

If you’ve got some more solutions to this problem, it will be so nice of you to share them here!

Thanks for Reading.

Article written by

I am an Engineering Student, a Tech Blogger and owner of TechnoDoze.com. I write on several topics such as Gadgets, iPhone releases, tips and tricks and other helping stuff that you may like. Meet me at Facebook. More Info About Me.

Leave a Reply