XHTML Strict validation or target attribute?

Recently I found that some of my pages were not of valid XHTML Strict doctype and the culprit is the target attribute in my tag which I used to open external pages in new window.

With a little bit of googling I found that I was not the only one who is facing this issue. In addition to that I also found lot of hacks and JavaScript scripts to make the links open in a new window without using the target attribute. Notable among them are this Sitepoint article and the recent one by Roger.

Time to decide, whether I have to the remove target attribute or use these JavaScript hacks or make my XHTML documents as transitional doctype. I am certainly not interested to use the JavaScript hacks but at the same time don’t want to go back to transitional doctype also.

Since this is my personal site I had the liberty to choose what ever I wanted and I have decided to leave it as it is. But my decision would have been different (or would have taken more time) if it was one of my client’s pages. So here after all my pages will have the XHTML Strict doctype and also the target attribute. After all rules are meant to be broken right 😉 what do you guys say?

Related posts

Tags: , , ,

6 Comments so far

Follow up comments through RSS Feed | Post a comment

  • Yuvi says:

    Well, your site is much better than digg: It is atleast valid XML!

  • Sudar says:


    Better than Digg? Nice to hear that 🙂


  • Yuvi says:

    Well, try to parse it out with Regex or Normal Parsing for two days, and then it’ll be even nicer:D

    Though I did find a good library afterwards…

    But, if it were atleast as compliant as your’s, I wouldn’t have even required that library:D

  • Jason Marks says:

    You can still implement the strict DocType and still use the target attribute.

    If you use the standard HTML 4.01 strict doctype like so:

    You can change it to:

    <!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd” [ ]>

    This way you are still using the strict doctype, and the W3C validator will still pass your markup.

    This will allow the target attribute to be used on “a”, “link”, “area” and “form”.


  • Mara Alexander says:

    Just to note, that last recommendation by Jason is inaccurate. Only Transitional doctype allows the target attribute.

Leave a Reply

Your email address will not be published. Required fields are marked *