No more target attribute
Posted in Ramblings, Uncategorized on April 25th, 2007 by Peter Wooley – Be the first to commentAs soon as I learned that XHTML 1.1 disallows the use of the target attribute, I was torn. The ability to force links to open in new windows seems quite powerful. What if you want to link to off-site articles, but be sure to keep them on your site? The reason doesn’t even need to be selfish: wouldn’t it confuse the user if they left your site with no obvious way back? My hope would be that the Back button is now obvious, but perhaps we can’t count on that? For well over a year, I’ve been searching for just why target has been removed. Tonight, through a bit of research and a lot of link hopping, I unexpectedly found it:The reason for deprecating those items is that the W3C wants to promote the separation between content (HTML), presentation (CSS) and behaviour (JavaScript). Making an element centred [sic] within the viewport is a presentational issue; thus it should be handled by CSS instead of a center element. Opening a new browser window is a behavioural issue; thus it should be handled by JavaScript rather than a target attribute. —37 steps to perfect markupAnd it dawned on me. When I force a link to open in a new browser, I am telling the browser what to do; and JavaScript usually controls that. The argument that immediately came to mind was, “Well, when you link to something, you tell the browser to open that.” After some thought, I realized why I was wrong. When marking up, you are creating a relationship for the content to what it relates to. Using an anchor tag relates that marked up content to another document; you’re not telling the browser what to do at all, the browser’s default reaction is to open that document when clicked, simple as that.I’d suggest that everyone read Tommy Olsson’s Bulletproof HTML: 37 Steps to Perfect Markup. It may even make you re-consider your user of the i and b tags, if you can believe that.