Standards-Compliant, Accessible New Windows Without JavaScript
One of the reasons I’ve avoided using the XHTML 1.0 Strict DOCTYPE is that it doesn’t include the target attribute, which I use occasionally to open outside sites in a new window. It’s possible to do the same thing with JavaScript, but JavaScript may be turned off by your visitors for any number of reasons. What to do?
XHTML modularization to the rescue! Accessify.com has instructions on how to put together your own custom XHTML 1.1 Strict DOCTYPE, pulling in the XHTML module that allows you to use target and still validate. Slick!
NOTE: There are good reasons to just stick with the transitional DOCTYPE for now, mostly having to do with the way JavaScript operates in an XML environment vs. an HTML environment and with the known difficulties of properly serving strict XHTML using the application/xhtml+xml MIME type. Mark Pilgrim has written an excellent article for XML.com covering both issues. He’s also written a compelling weblog entry detailing a scenario in which the combination of strict XHTML, intolerant parsers, and invalid trackbacks and comments could cause a web site meltdown.
I’m looking forward to the day when such issues are resolved, so that this technology can get out of limbo and onto the web. Don Park has a good idea of how to do this with his “biased liberal” approach to XML parsing. I don’t expect such common sense to take hold any time soon, however, and from Don’s follow-up posts it sure doesn’t look promising. My guess is that either users will have to scream for this feature — or Microsoft will have to implement it first — before we see it catch on elsewhere.


I don’t usually add any sort of target to my links. Reason? Most browsers, given a link targeted to a new window, do not allow you to right-click and open the link in the same window. However, with no target, I can choose whatever I want.
It’s more a problem with the browser than anything, but in the end, choice is the key issue. Plus, most browsers don’t tell you whether a link will open in a new window or not. Given the mystery involved and the taking away of one choice, I’d rather the entire web be consistent and without targeted links, that way I can open new windows with a right-click; not something I need the site to decide for me. Some sites have a checkbox allowing you to choose whether external sites open in a new window or not, that way you always know. A step in the right direction, I think.
Well, that’s my take anyway. Regardless, there are times when you need things to open in a new window by default, such as complex web application interfaces. I believe A List Apart had a tutorial a while back on accessible popup windows. That might help you out.
Comment by Chris Vincent — December 20, 2004 @ 9:15 pm
You make a lot of good points, Chris, and it’s for many of those same reasons (and problems with pop-up blockers, too) that I quit using
target="outlink"for external links on this site. Now I only use it for links to commenters’ web sites on my photoblog, and I’ll probably be getting rid of it there soon.Still, I’ve always thought that the removal of
targetfrom XHTML was a little arbitrary. It’s interesting to see that there’s a way to get it back and still validate as strict. It makes me wonder how much other deprecated markup you could pull into strict XHTML if you were so inclined, and at what point the ability to do so starts to spoil the whole point of these new, leaner specs.Comment by Adam M. — December 20, 2004 @ 11:30 pm