<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Daniel Skinner: News and Articles on Web Development &#187; xhtml</title>
	<atom:link href="http://www.daniel-skinner.co.uk/tag/xhtml/feed" rel="self" type="application/rss+xml" />
	<link>http://www.daniel-skinner.co.uk</link>
	<description>Daniel Skinner&#039;s Blog: Web Development news and articles</description>
	<lastBuildDate>Wed, 18 Mar 2009 15:11:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Link Targets in XHTML</title>
		<link>http://www.daniel-skinner.co.uk/link-targets-in-xhtml/15/03/2008</link>
		<comments>http://www.daniel-skinner.co.uk/link-targets-in-xhtml/15/03/2008#comments</comments>
		<pubDate>Sat, 15 Mar 2008 13:33:56 +0000</pubDate>
		<dc:creator>Daniel Skinner</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.daniel-skinner.co.uk/link-targets-in-xhtml/15/03/2008</guid>
		<description><![CDATA[I always prefer to build websites in valid XHTML as it allows for a stricter, more maintainable envorinment to build websites than traditional HTML. However, there are a few features of HTML I like to make use of.
For example, making links open in new windows using the target attribute is unsupported by XHTML.

There are two [...]]]></description>
			<content:encoded><![CDATA[<p>I always prefer to build websites in <strong>valid <acronym title="eXtensible HyperText Markup Language">XHTML</acronym></strong> as it allows for a stricter, more maintainable envorinment to build websites than traditional <acronym title="HyperText Markup Language">HTML</acronym>. However, there are a few features of HTML I like to make use of.</p>
<p>For example, making links open in new windows using the <code>target</code> attribute is unsupported by XHTML.</p>
<p><span id="more-14"></span></p>
<p>There are two solutions I know of to get around this:</p>
<h4>1. JavaScript</h4>
<p>The DOM specification allows the use of the <code>target</code> attrbriute. So, mark each link you want to open in a new window using <code>rel="external"</code>. When the page loads use JavaScript to find all these links and add a <code>target="_blank"</code> to each using DOM.</p>
<p>In <strong>MooTools</strong> the code would look like:</p>
<pre type="javascript">
window.addEvent('domready', function() {
    // rel="external" links open in new window
    $$('a[href][rel="external"]').each(function(anchor) {
        anchor.setProperty('target', '_blank');
    });
});</pre>
<p>For a raw JavaScript solution and more information on this approach see this <a href="http://www.sitepoint.com/article/standards-compliant-world" title="Sitepoint Article: New Windows for links in XHTML" rel="nofollow external">Sitepoint article</a>.</p>
<h4>2. Extending XHTML</h4>
<p>Simply extend XHTML to support the <code>target</code> attribute and continue using <code>target="_blank"</code> whilst still producing perfectly valid XHTML!</p>
<p>Essentially you extend the default XHTML <acronym title="Document Type Definition">DTD</acronym> to enable the XHTML Target Module (which is not enabled by default) and then modify the page DOCTYPE definition to point to the extended <acronym title="Document Type Definition">DTD</acronym>.</p>
<p>The full details and how to implement it can be found here at <a href="http://www.texastar.com/tips/2004/target_blank.shtml" title="TexaStar: XHTML Modularization" rel="nofollow external">TexaStar</a>.</p>
<p>Currently I am using the JavaScript workaround. However, modifying the XHTML definition to make it work for me is a very elegant solution that I would look to implement in the future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.daniel-skinner.co.uk/link-targets-in-xhtml/15/03/2008/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
