<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Don&#8217;t use Javascript to hide bad markup</title>
	<atom:link href="http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/feed/" rel="self" type="application/rss+xml" />
	<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/</link>
	<description>the personal blog of Stuart Colville covering modern web development techniques and best practices</description>
	<pubDate>Sun, 07 Sep 2008 23:14:07 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: SneakyWho_am_i</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-64568</link>
		<dc:creator>SneakyWho_am_i</dc:creator>
		<pubDate>Sun, 31 Aug 2008 01:46:41 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-64568</guid>
		<description>Here are some opinions. I know it's been a long time but hey.

I can think of a reason I might be tempted to do it:
- so that I could still use the validator to debug my markup (ie by finding typos.. I like to keep it in verbose mode) without having it complain about invalid markup that I was dead-set on including.

However, after two years now, this article still holds true. I saw in the wild, in a script, someone had hidden some invalid markup in javascript to keep the page "valid". (I was appalled!)

Actually hiding it still invalidates the page, the validator is just not yet sophisticated enough to detect the errors.
If you're going to use invalid markup then you should just use it with all the confidence and knowledge that it is the right thing to do. You shouldn't need to hide it with javascript!!!

I try to write valid (XML) code, because I want to have access to things like XSL Transformations*. I try to write valid code because I like to be able to quickly spot debilitating errors in the validator(/s). I try to write valid (not quirks mode) code because it seems to apply a more consistent experience across browsers, and I want that without having to invest any extra effort**.
I think (well, of course, I would, wouldn't I?) that these are the right reasons for embracing XML and standards.
I think that hiding errors from the validator for the sake of getting a badge is just silly and counterproductive.

Hiding semantic code? That I'm not sure about. If it makes it more maintainable then it might not be so bad. If the non-semantic markup reduces the maintainability of your code then throw it away.

*, ** Offering non-quirks-mode xml doctypes incurs a very high set up cost with content negotiation and such so I'm not sure if it is right to call this achievable and still claim a consistent experience across browsers.
But it's still good to combine them where we can, because these things DO have some benefits, and if we don't use them they will disappear from the world and Internet Explorer / The Terrorists will have won.</description>
		<content:encoded><![CDATA[<p>Here are some opinions. I know it&#8217;s been a long time but hey.</p>
<p>I can think of a reason I might be tempted to do it:<br />
- so that I could still use the validator to debug my markup (ie by finding typos.. I like to keep it in verbose mode) without having it complain about invalid markup that I was dead-set on including.</p>
<p>However, after two years now, this article still holds true. I saw in the wild, in a script, someone had hidden some invalid markup in javascript to keep the page &#8220;valid&#8221;. (I was appalled!)</p>
<p>Actually hiding it still invalidates the page, the validator is just not yet sophisticated enough to detect the errors.<br />
If you&#8217;re going to use invalid markup then you should just use it with all the confidence and knowledge that it is the right thing to do. You shouldn&#8217;t need to hide it with javascript!!!</p>
<p>I try to write valid (XML) code, because I want to have access to things like XSL Transformations*. I try to write valid code because I like to be able to quickly spot debilitating errors in the validator(/s). I try to write valid (not quirks mode) code because it seems to apply a more consistent experience across browsers, and I want that without having to invest any extra effort**.<br />
I think (well, of course, I would, wouldn&#8217;t I?) that these are the right reasons for embracing XML and standards.<br />
I think that hiding errors from the validator for the sake of getting a badge is just silly and counterproductive.</p>
<p>Hiding semantic code? That I&#8217;m not sure about. If it makes it more maintainable then it might not be so bad. If the non-semantic markup reduces the maintainability of your code then throw it away.</p>
<p>*, ** Offering non-quirks-mode xml doctypes incurs a very high set up cost with content negotiation and such so I&#8217;m not sure if it is right to call this achievable and still claim a consistent experience across browsers.<br />
But it&#8217;s still good to combine them where we can, because these things DO have some benefits, and if we don&#8217;t use them they will disappear from the world and Internet Explorer / The Terrorists will have won.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-62949</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Sun, 07 Oct 2007 11:35:43 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-62949</guid>
		<description>@Kyle: Thanks for your comment but you've totally missed the point. I'm totally in favour of using javascript to enhance a page and I'm also well aware of the need to provide something that works for when JavaScript is available to the UA and when it isn't. 

What I &lt;em&gt;am&lt;/em&gt; against is adding mark-up via JavaScript when the only point is to hide the markup that is just there to provide hooks for an effect. It's totally pointless and that markup may as well be there in the first place. Also using spans which are sematically transparent you are not affecting the overall semantics of a document anyway.</description>
		<content:encoded><![CDATA[<p>@Kyle: Thanks for your comment but you&#8217;ve totally missed the point. I&#8217;m totally in favour of using javascript to enhance a page and I&#8217;m also well aware of the need to provide something that works for when JavaScript is available to the UA and when it isn&#8217;t. </p>
<p>What I <em>am</em> against is adding mark-up via JavaScript when the only point is to hide the markup that is just there to provide hooks for an effect. It&#8217;s totally pointless and that markup may as well be there in the first place. Also using spans which are sematically transparent you are not affecting the overall semantics of a document anyway.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-62787</link>
		<dc:creator>Kyle</dc:creator>
		<pubDate>Sun, 07 Oct 2007 00:18:51 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-62787</guid>
		<description>I'm making this post a year and a half after the original, but.. I &lt;em&gt;completely&lt;/em&gt; disagree with this article.  What is the purpose of semantic code and validation?  For accessibility and backward compatibility.

It makes perfect sense to add extra features with JavaScript, whether or not it's "valid markup,"  if it will gracefully be disregarded on a non-compliant browser.  If, shedding the JavaScript, the markup that will be rendered is semantic and contains all the necessary content for the user of a screen reader, mobile browser, or Lynx browser to get the info they need... by all means, make it cooler for people using browsers that can handle the JS!</description>
		<content:encoded><![CDATA[<p>I&#8217;m making this post a year and a half after the original, but.. I <em>completely</em> disagree with this article.  What is the purpose of semantic code and validation?  For accessibility and backward compatibility.</p>
<p>It makes perfect sense to add extra features with JavaScript, whether or not it&#8217;s &#8220;valid markup,&#8221;  if it will gracefully be disregarded on a non-compliant browser.  If, shedding the JavaScript, the markup that will be rendered is semantic and contains all the necessary content for the user of a screen reader, mobile browser, or Lynx browser to get the info they need&#8230; by all means, make it cooler for people using browsers that can handle the JS!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pavan</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-5242</link>
		<dc:creator>pavan</dc:creator>
		<pubDate>Wed, 14 Jun 2006 07:16:15 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-5242</guid>
		<description>one can hide their content using java script,but this method should be avoid because your web site may get penalty.</description>
		<content:encoded><![CDATA[<p>one can hide their content using java script,but this method should be avoid because your web site may get penalty.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-414</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Sat, 15 Apr 2006 01:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-414</guid>
		<description>@Paul and Jonathan: You are both right and make good points. The point I was making was that if the sole purpose of using javascript is to sweep either non-semantic or invalid markup under the carpet then this is wrong. 

I do accept that there are justified reasons for using JavaScript in this way if it provides additional benefits or functionality.</description>
		<content:encoded><![CDATA[<p>@Paul and Jonathan: You are both right and make good points. The point I was making was that if the sole purpose of using javascript is to sweep either non-semantic or invalid markup under the carpet then this is wrong. </p>
<p>I do accept that there are justified reasons for using JavaScript in this way if it provides additional benefits or functionality.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paul</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-410</link>
		<dc:creator>Paul</dc:creator>
		<pubDate>Fri, 14 Apr 2006 16:49:36 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-410</guid>
		<description>There may be other non-markup related reasons to use javascript to write Flash objects to a page - for example, doing javascript detection to check the browser has Flash installed and substitute an image (or something) if they don't.</description>
		<content:encoded><![CDATA[<p>There may be other non-markup related reasons to use javascript to write Flash objects to a page - for example, doing javascript detection to check the browser has Flash installed and substitute an image (or something) if they don&#8217;t.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Snook</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-313</link>
		<dc:creator>Jonathan Snook</dc:creator>
		<pubDate>Wed, 05 Apr 2006 13:28:18 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-313</guid>
		<description>There's a couple reasons why I can think of to use Javascript for rounded corners: A &#60;10k script may be far more efficient than the images, HTML and CSS required to pull off multiple rounded corners. Yet you'd still have the benefits of a really clean source for redesigns.

There's no hard-and-fast rules on this. The important lesson is to evaluate the best solution for the situation.</description>
		<content:encoded><![CDATA[<p>There&#8217;s a couple reasons why I can think of to use Javascript for rounded corners: A &lt;10k script may be far more efficient than the images, HTML and CSS required to pull off multiple rounded corners. Yet you&#8217;d still have the benefits of a really clean source for redesigns.</p>
<p>There&#8217;s no hard-and-fast rules on this. The important lesson is to evaluate the best solution for the situation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stuart Colville</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-301</link>
		<dc:creator>Stuart Colville</dc:creator>
		<pubDate>Tue, 04 Apr 2006 08:07:49 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-301</guid>
		<description>@Mike: I'll agree to disagree with you on your first point ;-). It's still good to hear differing views on this subject. 

For me I can't see why anyone would decide to use JavaScript to obscure non-semantic markup. If you make the design decision to add non-semantic markup for whatever reason then you should stand by it and not need to hide it away.</description>
		<content:encoded><![CDATA[<p>@Mike: I&#8217;ll agree to disagree with you on your first point ;-). It&#8217;s still good to hear differing views on this subject. </p>
<p>For me I can&#8217;t see why anyone would decide to use JavaScript to obscure non-semantic markup. If you make the design decision to add non-semantic markup for whatever reason then you should stand by it and not need to hide it away.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike Ebert</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-300</link>
		<dc:creator>Mike Ebert</dc:creator>
		<pubDate>Tue, 04 Apr 2006 07:05:53 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-300</guid>
		<description>I wouldn't totally condemn adding source code through Javascript--in fact, it's a rather ingenious way to get the appearance you want out of your site while we all wait for browsers and standards to catch up. One day you won't need 4 to 8 extra divs to get pretty rounded corners. And when that day arrives, you simply remove the extra code from your JS.

I do agree, however, that there are many instances when this method can be abused, such as including invalid code.

So including valid, but not semantically necessary, markup is ok in my book, but including invalid markup is no better than putting it right in the source.</description>
		<content:encoded><![CDATA[<p>I wouldn&#8217;t totally condemn adding source code through Javascript&#8211;in fact, it&#8217;s a rather ingenious way to get the appearance you want out of your site while we all wait for browsers and standards to catch up. One day you won&#8217;t need 4 to 8 extra divs to get pretty rounded corners. And when that day arrives, you simply remove the extra code from your JS.</p>
<p>I do agree, however, that there are many instances when this method can be abused, such as including invalid code.</p>
<p>So including valid, but not semantically necessary, markup is ok in my book, but including invalid markup is no better than putting it right in the source.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andrew</title>
		<link>http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-279</link>
		<dc:creator>Andrew</dc:creator>
		<pubDate>Fri, 31 Mar 2006 13:59:37 +0000</pubDate>
		<guid isPermaLink="false">http://muffinresearch.co.uk/archives/2006/03/30/dont-use-javascript-to-hide-bad-markup/#comment-279</guid>
		<description>I didn't realize that “View Selection Source” did that. Very handy!</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t realize that “View Selection Source” did that. Very handy!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
