XHTML 1.1 Second Edition with Target Attribute

When I switched from HTML 4 to XHTML 1.1 a couple of years ago, I soon found the target attribute was missing. I have never been in love with the target attribute anyway, but some clients insisted that their links should open in a new window. So I did some research.

You won’t believe how much myth and misinformation is out there. Some say it’s deprecated. In fact it never was. It is part of XHTML 2 and XHTML Basic, and there is a target module in XHTML 1.1, the modularized version of XHTML. The attribute is not included in HTML 4.01 Strict and XHTML 1.0 Strict because it was then considered to be related to frames and iframes, but it’s not marked “deprecated.” It was simply not in the core set of modules for the XHTML 1.1 driver.

Some people argued it’s a behavior and thus belongs into unobtrusive JavaScript. But then clicking on a link to get to another page is also some functionality, and nobody would think of replacing anchors with loads of bloated script to simulate such a basic behavior.

So I ended up extending the extensible with a customized DTD:

  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!-- Bring in the XHTML 1.1 driver -->
  3. <!ENTITY % xhtml11.dtd
  4. PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  5. "http://www.w3.org/TR/xhtml11/ DTD/xhtml11.dtd">
  6. %xhtml11.dtd;
  8. <!-- Bring in the Target Module -->
  9. <!ENTITY % xhtml-target.mod
  10. PUBLIC "-//W3C//ELEMENTS XHTML Target 1.0//EN"
  11. "http://www.w3.org/TR/ xhtml-modularization/DTD/ xhtml-target-1.mod">
  12. %xhtml-target.mod;

However, now I have to bid farewell to that bizarre old friend: the working draft of XHTML 1.1 Second Edition includes the target module in the core set, finally. I’m relieved because tinkering with DTDs is a pain, but it had style …

Note that in the current version target is not yet included in XHTML 1.1 Schema, but I have been assured it will definitely be in the final version.

9 Responses to ‘XHTML 1.1 Second Edition with Target Attribute’

  1. accessBlog » Neues vom W3C...

    […] Martin Kliehm weist zu Recht darauf hin, dass das target-Attribut auf wundersame Weise seinen Weg zurück in das Core Set von XHTML 1.1 gefunden hat. […]

  2. lillbra » Target-attributet och öppna länkar i nytt fönster

    [...] Martin Kliehm Martin Kliehm presenterar ett sista alternativt sätt att öppna länkar i nytt fönster, och det är att använda sig av XHTML 1.1 och modifiera DTD:n. Genom att importera target-modulen gör man target-attributet möjligt att använda. Detta verkar krångligt och är väl inte heller så aktuellt, eftersom XHTML 1.1 ändå inte kan tolkas av Internet Explorer. [...]

  3. Marina

    I was searching for an answer to the question of whether _blank is still valid XHTML when I found this page.

    After quite a bit of Googling and reading, I also found the following very simple, very elegant answer, which I tested successfully in Firefox 2.0, IE7, and Opera 9.21 and which validates at validator.w3.org as XHTML 1.0 strict and XHTML 1.1 (with the proper declarations, of course):

    It was in comment #19 in the comments section of this Web page.

  4. Martin Kliehm

    Marina, adding some onclick="target='_blank'" is indeed simple. Like I said, extending the DTD is a pain with some drawbacks. Jesse Skinner’s solution is slightly more complicated, but it works unobtrusive, without inline JavaScript. So it’s better maintainable. In the end it’s a political decision, it’s about your own preferences. There is no best solution. ;)

  5. Marina


    On thinking about it further, Jesse’s solution is a better one from the elegant standpoint, since you define the class and let the code do the work.

    I was actually researching this for someone else, since I don’t like to open new windows.

  6. Arthur

    The target attribute isn’t just for opening new windows. Using the object tag to embed one document in another should allow for target="_parent" or "_top" to work as well.

  7. Busy

    This was a really good post, especially the misinformation part. (And the good news for the next edition of XHTML.)

    I use javascript on new windows anyways (because I typically only use them for little ones that I want a certain size) but I always let my pages fail with the target="" error out of protest.

    No more failed pages, hooray!

  8. Mark Claudius Png

    There is a JavaScript workaround. Very compact when used with the Mootools framework.

  9. Marius

    All those hacks with onclick=”target=’blank’” is nonsense! While your page is XHTML valid, your Javascript isn’t. I mean, if some browser is able to open link in new tab with that javascript, it will definately open new tab with simple target=”_blank” declaration. And if it doesn’t understand the target attribute (because XHML doesn’t require it to), I don’t think that whole page will broke if you leave that target attribute in the “a” tag. And the solution with Javascript still won’t work. All you get from all those hacks is green tick in the validator. I mean, if all those XHTMLs were created to make user experience better, these hacks just make it worse. If user doesn’t have Javascript, _blank won’t work for him. And I think not having Javascript (enabled) is far more often than browser without target attribute support.

    Thinking about users, I’ll definately still use target=”_blank” attribute in my pages. And if I’d want that green tick very badly, I’d go with that DTD expanding, because it’s only between your page and validator, don’t get users involved into this.