<?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>The Bright Lines &#187; IE6</title>
	<atom:link href="http://www.thebrightlines.com/tag/ie6/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thebrightlines.com</link>
	<description>HTML, CSS, Javascript and more</description>
	<lastBuildDate>Thu, 29 Jul 2010 22:44:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hack: how to enable :first-child in IE6</title>
		<link>http://www.thebrightlines.com/2010/01/31/hack-how-to-enable-first-child-in-ie6/</link>
		<comments>http://www.thebrightlines.com/2010/01/31/hack-how-to-enable-first-child-in-ie6/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 00:43:14 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[first-child]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[IE6]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=433</guid>
		<description><![CDATA[How to implement the CSS selector :first-child in IE6 with a little help from Javascript.]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> The pure Javascript routine is updated. It is now as fast as jQuery.</p>
<p>One of the things I most dearly miss in IE6 is the lack of support for the CSS selector <code>:first-child</code>. Some shortcomings in browsers can be patched with Javascript. And <code>:first-child</code> is one of them for sure. If you use a Javascript library like jQuery or Prototype it&#8217;s just one line of Javascript:</p>
<pre name="code" class="xhtml:nogutter">&lt;!--[if lte IE 6]&gt;
    &lt;script type="text/javascript"&gt;
        jQuery("*:first-child").addClass("firstChild")
    &lt;/script&gt;
&lt;![endif]--&gt;</pre>
<p>If you don&#8217;t like Javascript libraries you can use this pure js-code:</p>
<pre name="code" class="xhtml:nogutter">
var tags = document.getElementsByTagName("*"); var nTags = tags.length;
for (var i=0;i<nTags;i++) {
	if (tags[i].firstChild) {
		var el=tags[i].firstChild; while ((el.nodeType!=1)&#038;&#038;(el.nextSibling)) el=el.nextSibling;
		if (el.nodeType==1) el.className += " firstChild";
	}
}
</pre>
<p>Now every first child has the class <code>firstChild</code> that can be used in CSS selectors. You'll get something like this:</p>
<pre name="code" class="css:nogutter">
ul li:first-child,
ul li.firstChild {
    font-weight: bold;
}
</pre>
<h2>The speed</h2>
<p>Throwing around classes through the whole HTML tree is not without a price. Certainly not if you keep in mind that Javascript in IE6 is much slower than in Firefox or Safari. So I tested what would happen if the Javascript would run in the homepage of amazon.com, a page with almost a 1000 tags. Here are the results:</p>
<ul>
<li><strong>Adding firstChild with jQuery:</strong>
<ul>
<li>Amazon.com homepage (1000 tags): +- <strong>215</strong>milliseconds</li>
<li>Five times the Amazon.com homepage (5000 tags): +- <strong>742</strong> milliseconds</li>
</ul>
</li>
<li>Adding firstChild with plain Javascript:
<ul>
<li>Amazon.com homepage (1000 tags): +- <strong>129</strong> milliseconds</li>
<li>Five times the Amazon.com homepage (5000 tags): +- <strong>798</strong> milliseconds</li>
</ul>
</li>
</ul>
<p>As you can see there is not much performance difference. Especially when you keep in mind that every time I ran my test page I got different results. With a page of 5000 tags it could run as fast as 481 milliseconds or as slow as 931.</p>
<h2>Code crafting</h2>
<p>The first test I did with the pure Javascript code gave different results because of a inefficient routine. It ran about 1/3 slower in the 1000-tag page and 4 times slower in a 5000-tag page. After consulting a colleague I was able to find a more efficient routine that could match with jQuery.</p>
<h2>Conclusion</h2>
<p>I think a lag of about 200 milliseconds during a page load with a 1000 tags can be acceptable. Especially since a web page of 1000 tags is already a large website to my standards. Most websites I develop have about 300 tags a page at best. If you want to use this hack, I guess it's best to test the script in the largest pages of the website. The gain isn't that spectacular: just support for :first-child. But on the other side it could really make your life as a web developer just a bit easier.</p>
<p>You might be tempted to patch other shortcomings of IE6 with Javascript. Don't start coding, but consider the <a href="http://code.google.com/p/ie7-js/">IE7.js-script</a>. But I must say up front that I don't have good experiences with it. The script works good in small pages with small CSS files, but you'll experience serious performance issues with medium or large websites.</p>
<h2>Putting it in perspective</h2>
<p>Chrome 4, by the way needed just 37 milliseconds to run the Javascript in the 5000-tag page. That's 20 times faster then IE6.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2010/01/04/alternative-for-nth-of-type-and-nth-child/' rel='bookmark' title='Permanent Link: Alternative for :nth-of-type() and :nth-child()'>Alternative for :nth-of-type() and :nth-child()</a></li>
<li><a href='http://www.thebrightlines.com/2009/10/28/for-the-sloppy-clickers/' rel='bookmark' title='Permanent Link: For the sloppy clickers'>For the sloppy clickers</a></li>
<li><a href='http://www.thebrightlines.com/2009/12/24/too-advanced-css-selectors/' rel='bookmark' title='Permanent Link: Too advanced CSS selectors'>Too advanced CSS selectors</a></li>
<li><a href='http://www.thebrightlines.com/2009/11/08/how-to-overcome-the-limits-of-css-in-internet-explorer-6/' rel='bookmark' title='Permanent Link: How to overcome the limits of CSS in Internet Explorer 6'>How to overcome the limits of CSS in Internet Explorer 6</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2010/01/31/hack-how-to-enable-first-child-in-ie6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to overcome the limits of CSS in Internet Explorer 6</title>
		<link>http://www.thebrightlines.com/2009/11/08/how-to-overcome-the-limits-of-css-in-internet-explorer-6/</link>
		<comments>http://www.thebrightlines.com/2009/11/08/how-to-overcome-the-limits-of-css-in-internet-explorer-6/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 23:36:17 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=114</guid>
		<description><![CDATA[The possibilities with CSS has been growing the last years, but we're still stuck with IE6. That doesn't always mean we have to wait for IE6 to disappear from the scene.]]></description>
			<content:encoded><![CDATA[<p>Although the support of CSS selectors hasn&#8217;t improved dramatically since IE6, we can use some selectors in IE7 and IE8 that really help to style web pages without creating a class for everything that needs styling. Those selectors are:</p>
<ul>
<li>Child selector: <code>.parent &gt; .child</code></li>
<li>First child selector: <code>.parent .child:first-child</code></li>
<li>Adjacent selector: <code>.sibling + .sibling</code></li>
</ul>
<h2>Where IE6 falls short</h2>
<p>Some situations just scream for one of those three selectors that aren&#8217;t supported in IE6. Take a list like the one below for example:</p>
<pre name="code" class="xhtml:nogutter">
<ul>
<li>Lorem
<ul>
<li>Ipsum</li>
<li>Dolor</li>
<li>Sit
<ul>
<li>Amet</li>
</ul>
</li>
</ul>
</li>
<li>Dolor</li>
</ul>
</pre>
<p>If you want to style the list items you can do so with a simple selector:</p>
<pre name="code" class="css:nogutter">
ul li {
	font: bold normal 14px/1.5em Arial
}
</pre>
<p>But what if you want to style only the <code>li</code>&#8217;s in the <i>first</i> level? Well, you either have to give all first level list items a class so you can target specifically those elements, or you have to add some more reset code to remove unwanted styling like this:</p>
<pre name="code" class="css:nogutter">
ul li { /* set styling for all list items */
	font: bold normal 14px/1.5em Arial
}

ul li li { /* reset styling for all list items except for the first level */
	font-size: 12px;
	font-weight: normal
}
</pre>
<p>Both solutions have their drawbacks:</p>
<ul>
<li>It&#8217;s not always possible to add classes to the HTML when, for example, the HTML is generated with serverside code. This is especially true when you&#8217;re not a programmer or the serverside code cannot be accessed.</li>
<li>If you have lots of styles and levels it&#8217;s hard to keep track of what styling you have to reset</li>
</ul>
<p>So let&#8217;s style it another way that&#8217;s possible in all major browsers except IE6:</p>
<pre name="code" class="css:nogutter">
ul > li { /* set styling list items in first level */
	font: bold normal 14px/1.5em Arial
}
</pre>
<h2>Fix it with jQuery</h2>
<p>Now what to do with IE6? In case I have to use incompatible selectors I call in the help of Javascript by using the popular jQuery library. That&#8217;s because with jQuery I <em>can</em> use advanced selectors. You&#8217;ll get something like the two snippets below</p>
<pre name="code" class="css:nogutter">
ul > li,
li.level1 { /* set styling list items in first level */
	font: bold normal 14px/1.5em Arial
}
</pre>
<pre name="code" class="javascript:nogutter">
jQuery("ul > li").addClass("level1"); /* adds class to spcific elements for IE6 */
</pre>
<h2>Fix it with IE7.js</h2>
<p>Some of you may say there&#8217;s a better solution than patching your website manually with jQuery. For years there&#8217;s a script called <a href="http://code.google.com/p/ie7-js/">IE7.js</a> which patches many shortcomings of IE6 and &#8220;upgrades&#8221; your website to IE7. I tried it but it wasn&#8217;t a succes, if not a failure for 2 reasons:</p>
<ul>
<li><strong>It fixes a lot of bugs but introduces a few at the same time.</strong> Eventually I still had to use jQuery to patch bugs that came out of IE7.js.</li>
<li><strong>It slows your website.</strong>. IE7.js does a lot for you, but it costs CPU power. At first the time IE7.js needs to do its work is minute and you will only see a short glitch. But when your CSS file grows larger than say 1000 lines, the page will freeze for a second or more. Bad user experience.</li>
</ul>
<p>So although IE7.js is a good initiative it doesn&#8217;t scale well for medium or large websites. You will be better off fixing little incompatibilities with jQuery or any other library that gives the freedom to use CSS selectors in Javascript. Or in some cases: don&#8217;t fix it at all.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2009/12/24/too-advanced-css-selectors/' rel='bookmark' title='Permanent Link: Too advanced CSS selectors'>Too advanced CSS selectors</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/31/hack-how-to-enable-first-child-in-ie6/' rel='bookmark' title='Permanent Link: Hack: how to enable :first-child in IE6'>Hack: how to enable :first-child in IE6</a></li>
<li><a href='http://www.thebrightlines.com/2010/01/04/alternative-for-nth-of-type-and-nth-child/' rel='bookmark' title='Permanent Link: Alternative for :nth-of-type() and :nth-child()'>Alternative for :nth-of-type() and :nth-child()</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2009/11/08/how-to-overcome-the-limits-of-css-in-internet-explorer-6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Banning IE6 is banning visitors</title>
		<link>http://www.thebrightlines.com/2009/10/24/respect-users-with-ie6/</link>
		<comments>http://www.thebrightlines.com/2009/10/24/respect-users-with-ie6/#comments</comments>
		<pubDate>Sat, 24 Oct 2009 19:19:33 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[IE6]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=33</guid>
		<description><![CDATA[Web developers are campaigning against IE6. A bit too early if you ask me. More than 10% of the internet users browse the net with IE6.]]></description>
			<content:encoded><![CDATA[<p><img class="alignleft" title="Save IE6" src="/article-data/images/badge_saveie6.gif" alt="Save IE6" width="113" height="118" />This year the hunt was opened for IE6. Web developers are fed up with the browser that had been around since 2001. If you want that your website supports IE6, you limit your possibilities. So some decided to do start a campaign against IE6.</p>
<p>This situation is not new. Before IE6 everyone had to deal with the ancient Netscape 4.7 that just not seem to be willing to die. I decided not to support IE6 for The Bright Lines. But that was an easy decision to make: this website focuses on web developers. And those people do care about new browsers with new features. Since I could not imagine a web developer that feels comfortable with IE6 as his main browser I dropped the whole idea of supporting IE6.</p>
<p>But what if I would target a more general public? Than I would support IE6 without (much) hesitation. IE6 might be the most crappiest browser at the moment, it is still one of the major browsers with a market share of more than 10%. That&#8217;s still more than Chrome, Safari or Opera.</p>
<p>And why did you start a website in the first place? To publish content. If that&#8217;s your goal I wouldn&#8217;t risk scaring away one out of every 10 visitors. IE6 didn&#8217;t scare us from making websites in 2003, so why would it now?</p>
<p>By the way, if you want to have a laugh: <a title="Save IE6" href="http://www.saveie6.com/">visit this funny answer to all the &#8220;Ban IE6&#8243;-websites</a>.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2009/10/24/respect-users-with-ie6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
