<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Understanding and solving the JavaScript/CSS entanglement phenomenon</title>
	<atom:link href="http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/feed/" rel="self" type="application/rss+xml" />
	<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/</link>
	<description>Web Standards, Web Culture, Web Everything.™</description>
	<lastBuildDate>Sun, 25 Sep 2011 04:23:30 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: &#187; CSS Collection II 2008 CSS Concept: CSS can be just that easy..</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-40715</link>
		<dc:creator>&#187; CSS Collection II 2008 CSS Concept: CSS can be just that easy..</dc:creator>
		<pubDate>Tue, 27 May 2008 18:55:47 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-40715</guid>
		<description>[...] Understanding and Solving the JavaScript [...]</description>
		<content:encoded><![CDATA[<p>[...] Understanding and Solving the JavaScript [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: All in a days work&#8230;</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-8018</link>
		<dc:creator>All in a days work&#8230;</dc:creator>
		<pubDate>Sun, 04 Mar 2007 15:33:26 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-8018</guid>
		<description>[...] Understanding and solving the HTML/JavaScript/CSS entanglement phenomenon, one layer should never br... dependency should be unidirectional–downward, A lot of implementations will hide content in CSS and only make it available through JavaScript, thus tangling the two layers together and breaking the separation model. The following solutions avoid this ph (tags: HTML JavaScript CSS WebDesign) [...]</description>
		<content:encoded><![CDATA[<p>[...] Understanding and solving the HTML/JavaScript/CSS entanglement phenomenon, one layer should never br&#8230; dependency should be unidirectional–downward, A lot of implementations will hide content in CSS and only make it available through JavaScript, thus tangling the two layers together and breaking the separation model. The following solutions avoid this ph (tags: HTML JavaScript CSS WebDesign) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jrf</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7622</link>
		<dc:creator>Jrf</dc:creator>
		<pubDate>Sun, 25 Feb 2007 22:40:59 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7622</guid>
		<description>Nice idea.

Even so, I&#039;ll think I&#039;ll stick to the method I&#039;ve been using as I:
a) don&#039;t agree with having javascript in the html document (and most definitely not within the body) - this should be in a seperate file.
b) find it useful (and far less confusing) to work with two seperate css files: one which contains the &quot;normal&quot; state of a page, one which adds/overwrites the normal state for those users which have js available.

The technique I use is a variation on the first method. It *does* use document.write, but from within the js file.
I don&#039;t mind it being &quot;tied to a specific place in the document&quot; as that place is and should always be the same anyway: the js file should load from the head after the css file has been loaded.

For those interested: I&#039;ve described this method in more detail as part of an accessible fold-out menu tutorial here:
http://adviesenzo.nl/examples/cssjsmenu/</description>
		<content:encoded><![CDATA[<p>Nice idea.</p>
<p>Even so, I&#8217;ll think I&#8217;ll stick to the method I&#8217;ve been using as I:<br />
a) don&#8217;t agree with having javascript in the html document (and most definitely not within the body) &#8211; this should be in a seperate file.<br />
b) find it useful (and far less confusing) to work with two seperate css files: one which contains the &#8220;normal&#8221; state of a page, one which adds/overwrites the normal state for those users which have js available.</p>
<p>The technique I use is a variation on the first method. It *does* use document.write, but from within the js file.<br />
I don&#8217;t mind it being &#8220;tied to a specific place in the document&#8221; as that place is and should always be the same anyway: the js file should load from the head after the css file has been loaded.</p>
<p>For those interested: I&#8217;ve described this method in more detail as part of an accessible fold-out menu tutorial here:<br />
<a href="http://adviesenzo.nl/examples/cssjsmenu/" rel="nofollow">http://adviesenzo.nl/examples/cssjsmenu/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mirek Komárek</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7464</link>
		<dc:creator>Mirek Komárek</dc:creator>
		<pubDate>Thu, 22 Feb 2007 18:02:51 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7464</guid>
		<description>For ofline testing you can use mark of the web http://msdn.microsoft.com/workshop/author/dhtml/overview/motw.asp</description>
		<content:encoded><![CDATA[<p>For ofline testing you can use mark of the web <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/motw.asp" rel="nofollow">http://msdn.microsoft.com/workshop/author/dhtml/overview/motw.asp</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Curtis</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7462</link>
		<dc:creator>Ben Curtis</dc:creator>
		<pubDate>Thu, 22 Feb 2007 17:48:24 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7462</guid>
		<description>@mike 2k:)2:

Some browsers do not automatically have the document.documentElement object. I&#039;ve corrected this in my library with this line of code:

if (!document.documentElement) document.documentElement = document.getElementsByTagName(&#039;html&#039;)[0];

Sorry I didn&#039;t include that -- I thought it was for an ancient browser and not something still in use like IE. Guess I gotta comment my code...

I can&#039;t help you with the local/online issue, but if you&#039;re doing serious development you might want to explore running a webserver on your local machine. You can find easy installers for &quot;WAMP&quot; server configs just through a google search.</description>
		<content:encoded><![CDATA[<p>@mike 2k:)2:</p>
<p>Some browsers do not automatically have the document.documentElement object. I&#8217;ve corrected this in my library with this line of code:</p>
<p>if (!document.documentElement) document.documentElement = document.getElementsByTagName(&#8216;html&#8217;)[0];</p>
<p>Sorry I didn&#8217;t include that &#8212; I thought it was for an ancient browser and not something still in use like IE. Guess I gotta comment my code&#8230;</p>
<p>I can&#8217;t help you with the local/online issue, but if you&#8217;re doing serious development you might want to explore running a webserver on your local machine. You can find easy installers for &#8220;WAMP&#8221; server configs just through a google search.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike 2k:)2</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7449</link>
		<dc:creator>mike 2k:)2</dc:creator>
		<pubDate>Thu, 22 Feb 2007 14:39:49 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7449</guid>
		<description>Yes, but normally once the security risk is accepted the JS runs/ works. 
Though my PC has been playing up today. 
Works perfectly when online.</description>
		<content:encoded><![CDATA[<p>Yes, but normally once the security risk is accepted the JS runs/ works.<br />
Though my PC has been playing up today.<br />
Works perfectly when online.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ara Pehlivanian</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7447</link>
		<dc:creator>Ara Pehlivanian</dc:creator>
		<pubDate>Thu, 22 Feb 2007 14:18:59 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7447</guid>
		<description>&lt;strong&gt;mike 2k:)2&lt;/strong&gt;: I&#039;m not sure what you mean by the technique not working locally. Is it because you&#039;re using IE and it blocks JavaScript on locally loaded files by default?</description>
		<content:encoded><![CDATA[<p><strong>mike 2k:)2</strong>: I&#8217;m not sure what you mean by the technique not working locally. Is it because you&#8217;re using IE and it blocks JavaScript on locally loaded files by default?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike 2k:)2</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7445</link>
		<dc:creator>mike 2k:)2</dc:creator>
		<pubDate>Thu, 22 Feb 2007 14:08:39 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7445</guid>
		<description>Nice work dudes.I
s there a specific reason that these techniques work online but not locally?</description>
		<content:encoded><![CDATA[<p>Nice work dudes.I<br />
s there a specific reason that these techniques work online but not locally?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mike 2k:)2</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7440</link>
		<dc:creator>mike 2k:)2</dc:creator>
		<pubDate>Thu, 22 Feb 2007 12:12:34 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7440</guid>
		<description>Thanks Ara for opening this topic, brilliant.

I&#039;ve been struggling to prevent accessible hidden content from flashing up on page load.
Tried the domready technique but wasn&#039;t impressed with the results.
Even tried placing hidden content in  tags then redefining via the DOM. Unfortunately Firefox has a bug.

I prefer Ben&#039;s method purely for removing script from the body but I cannot get it to work with IE.
Any workarounds Ben or just use Ara&#039;s?</description>
		<content:encoded><![CDATA[<p>Thanks Ara for opening this topic, brilliant.</p>
<p>I&#8217;ve been struggling to prevent accessible hidden content from flashing up on page load.<br />
Tried the domready technique but wasn&#8217;t impressed with the results.<br />
Even tried placing hidden content in  tags then redefining via the DOM. Unfortunately Firefox has a bug.</p>
<p>I prefer Ben&#8217;s method purely for removing script from the body but I cannot get it to work with IE.<br />
Any workarounds Ben or just use Ara&#8217;s?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Curtis</title>
		<link>http://arapehlivanian.com/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/comment-page-1/#comment-7312</link>
		<dc:creator>Ben Curtis</dc:creator>
		<pubDate>Tue, 20 Feb 2007 22:03:48 +0000</pubDate>
		<guid isPermaLink="false">http://arapehlivanian.com/2007/02/14/understanding-and-solving-the-javascriptcss-entanglement-phenomenon/#comment-7312</guid>
		<description>I have been applying this technique to the html element for about two years now, without any drawbacks that I can see. Cezary Okupski rightfully points out that the class attribute is not a valid attribute for the html element in any of the appropriate DTDs, but it is important to note two things about that:

1. DTDs are created to validate the document as it is delivered, and not the interpreted or modified document held in memory by the client app. Thus, class attributes added to the html tag are invalid, but className values added to the html element via js are perfectly valid.

2. CSS selectors do not check themselves against the html DTD, and any element can have any class, so long as both the class and element name follow the proper naming convention (e.g., not starting with a number, no spaces, etc.).

So, it is valid to add className values to the html element, and to target your CSS selectors to it.

The pattern that I use is this:
a) when the JS executes, add one permanent and one temporary className:
document.documentElement.className += &#039; domCapable domLoading&#039;;

b) after the DOM has been loaded (via a similar technique to the JQuery &quot;ready&quot;), replace the temp className with one that recognizes the new state:
document.documentElement.className += &#039; domReady&#039;;
document.documentElement.className = document.documentElement.className.replace(/\bdomLoading\b/,&#039;&#039;).replace(/\s+/,&#039; &#039;);

Most of my &quot;hide until JS runs&quot; CSS then goes like this, where the &quot;off&quot; state is triggered by the html class and the &quot;on&quot; state is both the default and triggered by a class interactively added by JS:

html.domCapable #foo ul { display:none; }
#foo ul,
div#foo ul.show { display:block; }

(Notice the extra specificity of the added &quot;div&quot; in the &quot;on&quot; state to match the &quot;off&quot; state specificity -- you could also just remove the &quot;html&quot; from the &quot;off&quot; state selector.)</description>
		<content:encoded><![CDATA[<p>I have been applying this technique to the html element for about two years now, without any drawbacks that I can see. Cezary Okupski rightfully points out that the class attribute is not a valid attribute for the html element in any of the appropriate DTDs, but it is important to note two things about that:</p>
<p>1. DTDs are created to validate the document as it is delivered, and not the interpreted or modified document held in memory by the client app. Thus, class attributes added to the html tag are invalid, but className values added to the html element via js are perfectly valid.</p>
<p>2. CSS selectors do not check themselves against the html DTD, and any element can have any class, so long as both the class and element name follow the proper naming convention (e.g., not starting with a number, no spaces, etc.).</p>
<p>So, it is valid to add className values to the html element, and to target your CSS selectors to it.</p>
<p>The pattern that I use is this:<br />
a) when the JS executes, add one permanent and one temporary className:<br />
document.documentElement.className += &#8216; domCapable domLoading&#8217;;</p>
<p>b) after the DOM has been loaded (via a similar technique to the JQuery &#8220;ready&#8221;), replace the temp className with one that recognizes the new state:<br />
document.documentElement.className += &#8216; domReady&#8217;;<br />
document.documentElement.className = document.documentElement.className.replace(/\bdomLoading\b/,&#8221;).replace(/\s+/,&#8217; &#8216;);</p>
<p>Most of my &#8220;hide until JS runs&#8221; CSS then goes like this, where the &#8220;off&#8221; state is triggered by the html class and the &#8220;on&#8221; state is both the default and triggered by a class interactively added by JS:</p>
<p>html.domCapable #foo ul { display:none; }<br />
#foo ul,<br />
div#foo ul.show { display:block; }</p>
<p>(Notice the extra specificity of the added &#8220;div&#8221; in the &#8220;on&#8221; state to match the &#8220;off&#8221; state specificity &#8212; you could also just remove the &#8220;html&#8221; from the &#8220;off&#8221; state selector.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

