For a while, I was striving to keep my markup compliant with the XHTML-strict specification. Specifically, I wanted the W3C Validator to pass my pages (nowadays I'm aiming for HTML5 compliance.)
However at times this can be frustrating, especially if you're used to how browsers worked at the turn of the century.
One difficulty I faced involved forcing external pages to launch in their own window (or tab for Mozilla users). XHTML
strict, in fact no strict HTML specification has ever included the 'target' attribute for anchor elements. Instead,
we're advised to use
Instead of this code:
Use this much more concise code:
head section of your HTML document:
xhtml-external-links.js scans all links in your document and attaches it's own event handler
to open the link in a new window if the
external value is contained within the
attribute. Note that other values (such as
nofollow) may exist
rel attribute is defined as a space separated list.
xhtml-external-links.js - right-click and choose save as