<?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; Browsers</title>
	<atom:link href="http://www.thebrightlines.com/category/browsers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thebrightlines.com</link>
	<description>HTML, CSS, Javascript and more</description>
	<lastBuildDate>Tue, 17 Jan 2012 22:00:35 +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>The last resort in CSS debugging</title>
		<link>http://www.thebrightlines.com/2011/09/08/the-last-resort-in-css-debugging/</link>
		<comments>http://www.thebrightlines.com/2011/09/08/the-last-resort-in-css-debugging/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 10:32:52 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web development in general]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=910</guid>
		<description><![CDATA[CSS is in essence relatively simple: you point to one or more nodes in the DOM with a rule and apply some styles to it. That is the theory. In practice debugging CSS can be hard sometimes. Most of the time it's because either the code lacks the neccesary structure or you don't have arcane knowledge of browser bugs.]]></description>
			<content:encoded><![CDATA[<p>Even when you&#8217;re a structured CSS coder and know all the browser glitches (or <em>think</em> you do), it can happen you find yourself between a rock and a hard place. You know, when you stare at the screen, glancing over all the style properties in Firebug and still don&#8217;t have a clue about what&#8217;s going on.</p>
<h2>DEL is your friend</h2>
<p>Those cases happen rarely but when they do, I always resort to a tested and tried technique: isolate the problem by removing or commenting all unneeded markup. Isolating the problem may take some time but when you have a web page with a minimum of HTML while keeping the styling bug intact, you get in most cases the bug fixed in no time.</p>
<p>Why does isolating code work so well? Well, most of the time you can find styling bugs by experience, but when you&#8217;re stuck, every bit of styling on a tag becomes suspicious and that&#8217;s just too much to test. The bug becomes a needle in a hay stack.</p>
<h2>Removing the easy way</h2>
<p>The best way to remove blocks in a page is by just adding a <code>display: none</code> to its styling via a developer tool like Firefox&#8217;s Firebug, Opera&#8217;s Dragonfly, Webkits developer tools or IE&#8217;s Web Developer Toolbar. Just cut away big blocks and each time you remove something, you test if the bug still persists. You continue until you find the block that is triggering the bug. Most of the time you&#8217;ll have to continue the same technique of removing bits of code <em>within</em> that block until you can isolate the problem.</p>
<div class="wp-caption alignnone" style="width: 450px"><img title="Hiding block by adding a display: none" src="http://www.thebrightlines.com/article-data/images/debug1.png" alt="Hiding block by adding a display: none" width="440" height="221" /><p class="wp-caption-text">Hiding a block by adding a &#39;display: none&#39;</p></div>
<div class="wp-caption alignnone" style="width: 450px"><img title="Removing a block of HTML completely" src="http://www.thebrightlines.com/article-data/images/debug2.png" alt="Removing a block of HTML completely" width="440" height="221" /><p class="wp-caption-text">Removing a block of HTML completely</p></div>
<h2>Removing the source code</h2>
<p>Sometimes it&#8217;s better to have direct access to the source HTML than doing temporary changes in the developer tool. But if the HTML is (partly) created server side it&#8217;s hard to easily remove stuff. In those cases when I&#8217;m <em>really</em> desperate, I request the HTML source from the browser and save it in the directory the original web page resides. Then I can make dramatic changes to the code and test in multiple browsers without affecting the site itself.</p>
<p>Is this an efficient way of debugging? Definitely not, but sometimes you just need to do it. It happens to me once or twice a year or so and by debugging that way I always managed to find the root of the problem.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2009/10/22/css-debugging/' rel='bookmark' title='Permanent Link: CSS debugging'>CSS debugging</a></li>
<li><a href='http://www.thebrightlines.com/2011/11/21/debugging-less-css/' rel='bookmark' title='Permanent Link: Tips for using and debugging of Less CSS code'>Tips for using and debugging of Less CSS code</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2011/09/08/the-last-resort-in-css-debugging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The grey areas of progressive enhancement</title>
		<link>http://www.thebrightlines.com/2011/09/03/the-grey-areas-of-progressive-enhancement/</link>
		<comments>http://www.thebrightlines.com/2011/09/03/the-grey-areas-of-progressive-enhancement/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 05:42:12 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Web development in general]]></category>
		<category><![CDATA[Adaptive]]></category>
		<category><![CDATA[corporate identity]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[Progressive enhancement]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=889</guid>
		<description><![CDATA[Stepping up for the designers here: progressive enhancement is not always in the best interest of your client.]]></description>
			<content:encoded><![CDATA[<p>Yesterday I found the <a href="http://boagworld.com/design/where-are-my-rounded-corners/">PDF of Paul Boag on why progressive enhancement is better</a> than making sure that a website looks the same in all browsers, even older browsers like IE7. It&#8217;s just a 5-minute read and it&#8217;s a good stuff. But I can&#8217;t help feeling that the document presents a bit too black and and white picture. And it&#8217;s a picture in favor of frontend web developers.</p>
<p>For example: progressive enhancement in practice means that if you want to implement rounded corners, you&#8217;d use the <code>border-radius</code> style instead of a stack of images of rounded corners. But what if rounded corners are one of the corner stones of the corporate design of the client? Loads of users on IE7 and IE8 would miss that recognizable feature of that corporate design.</p>
<p>The design choice of rounded corners are sometimes a matter of taste, but most clients care for their corporate identity. So if you are ready to slaughter someones design in IE7/IE8 with progressive enhancement as your alibi, make sure that the features that will be missed in those browsers are not an important part of their corporate identity.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2010/01/07/do-you-create-your-design-in-photoshop-or-notepad/' rel='bookmark' title='Permanent Link: Do you create your design in Photoshop or Notepad?'>Do you create your design in Photoshop or Notepad?</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2011/09/03/the-grey-areas-of-progressive-enhancement/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Check your sites in IE9. Even if you use the X-UA meta tag</title>
		<link>http://www.thebrightlines.com/2011/03/13/check-your-sites-in-ie9-even-if-you-use-the-x-ua-meta-tag/</link>
		<comments>http://www.thebrightlines.com/2011/03/13/check-your-sites-in-ie9-even-if-you-use-the-x-ua-meta-tag/#comments</comments>
		<pubDate>Sun, 13 Mar 2011 20:19:05 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[x-ua]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=792</guid>
		<description><![CDATA[Since IE8 you can force an IE8+ browser to handle a website like it is an IE7 or an IE8 browser. IE9 seems to emulate older browsers well, but I know at least one rendering bug and I'm wondering if some backwards compatibility bugs are overlooked.]]></description>
			<content:encoded><![CDATA[<p>The Microsoft&#8217;s X-UA meta tag is simple. Just by adding <code>&lt;meta http-equiv="X-UA-Compatible" content="IE=7" /&gt;</code> to the HEAD you can make IE8 and IE9 handle a web page like it&#8217;s IE7. That way I can support 3 browser versions but having to test only one. It saves time that otherwise would be spent on testing.</p>
<p>Though it may seem like a good idea, the X-UA tag was initially received with mixed reactions. Some worried for example that web developers will become lazy and would only support IE7 even if Microsoft would roll out IE15. John Resig (creator of jQuery) even would go as far as calling the X-UA tag, <a href="http://ejohn.org/blog/meta-madness/">&ldquo;completely useless&rdquo; and &ldquo;harmful&rdquo;</a>. He thinks that the X-UA tag will just create more confusion because there will always be differences between a native IE7 and an emulated IE7.</p>
<p>I decided to use the meta-tag anyway. If it really didn&#8217;t work at all I could always remove the meta tag. On top of it: most websites I work on are not that complex and simplifying test procedures is a big plus.</p>
<h2>My experience with the X-UA</h2>
<p>Until now I had some good experiences with the X-UA tag, but I must say I have encountered 2 differences in rendering between a native IE7 and an emulated one. That&#8217;s not much if you consider that I use it ever since the meta tag was available, but it is something we have to look out for.</p>
<p>One of those 2 bugs happened just a while ago. We noticed that some website did not render well in IE9 with IE7 emulation. The text that was styled with custom web fonts (loaded with @font-face) was chopped off at the top and bottom. There was no problem in a native IE7 browser. The bug below shows that although IE7 emulation works pretty well, it still may have some glitches.</p>
<div class="wp-caption alignnone" style="width: 354px"><img alt="The line above is a screenshot from a native IE7. The line below is from an IE9 in IE7 mode. Both run on Vista." src="/article-data/images/x-ua.png" title="Missing the top line in IE9 in IE7 emulation  " width="344" height="36" /><p class="wp-caption-text">The line above is a screenshot from a native IE7. The line below is from an IE9 in IE7 mode. Both run on Vista.</p></div>
<p>So it may be worth while to check some old websites you created when you installed <a href="http://windows.microsoft.com/en-US/internet-explorer/products/ie/home?WT.mc_id=MSCOM_DLC_US_F_113LMUS004274">IE9</a>, <i>even</i> when you implemented the X-UA tag.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2011/03/13/check-your-sites-in-ie9-even-if-you-use-the-x-ua-meta-tag/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending media queries with JavaScript</title>
		<link>http://www.thebrightlines.com/2010/09/11/helping-browsers-with-media-queries/</link>
		<comments>http://www.thebrightlines.com/2010/09/11/helping-browsers-with-media-queries/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 22:21:25 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=677</guid>
		<description><![CDATA[Media queries are cool: you can decide what CSS file to serve to a browser based its width. But although it works perfect in many modern browsers, there are always some browsers or some versions of it lagging. Let's give them a hand.]]></description>
			<content:encoded><![CDATA[<div>
<a target="_blank" href="/article-data/demo/mqFallback" class="button demo"><span> </span>View demo</a><br />
<a style="clear: both" class="button download" href="/article-data/downloads/mqFallback.zip"><span></span>Download demo</a>
</div>
<div style="clear: both;"></div>
<h2>What are media queries</h2>
<p>To explain what media queries are, it&#8217;s best to start with the standard media types. Media types were introduced as part of the CSS2 specification way back in 1998 and is supported by all major browsers. The most common are &#8220;screen&#8221; (desktop PC&#8217;s), &#8220;handheld&#8221; (mobile devices), and &#8220;print&#8221;. Here&#8217;s an example of how to link a CSS file to a media type:</p>
<pre name="code" class="xhtml:nogutter">
<link rel="stylesheet" type="text/css" href="/screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/handheld.css" media="handheld" />
<link rel="stylesheet" type="text/css" href="/print.css" media="print" />
</pre>
<p>This looks pretty straightforward and it is. But most mobile browsers don&#8217;t consider themselves &#8220;handheld&#8221; when choosing a CSS file. Devices like iPhone, Android and Nokia behave like a desktop computer and select the CSS that&#8217;s reserved for the &#8220;screen&#8221;-devices.</p>
<p>This was in some way a logical step, since most websites don&#8217;t have a CSS file for handheld devices. The drawback is also very clear: You cannot cram a web page optimized for desktop monitors in a 2&#8242; handheld monitor without paying a price. Usability suffers. Users are given crutches like the ability to zoom in to a specific part of the page, but that&#8217;s like watching TV through a keyhole.</p>
<p>To address this problem the W3C came with media queries. Now you can check properties like screen size and resolution. So now you get something like this:</p>
<pre name="code" class="xhtml:nogutter">
<link rel="stylesheet" type="text/css" href="/screen.css" media="only screen and (min-width: 481px)" />
<link rel="stylesheet" type="text/css" href="/handheld.css" media="only screen and (max-width: 480px)" />
<link rel="stylesheet" type="text/css" href="/handheld.css" media="handheld" />
<link rel="stylesheet" type="text/css" href="/print.css" media="print" />
</pre>
<p>Now we have all our ducks back in a row. If the browser width is larger than 480 pixels, it will select &#8220;screen.css&#8221;. If the width is smaller or equal to 480 pixels, it will go for &#8220;handheld.css&#8221;. We keep our CSS link with <code>media="handheld"</code> as a fallback for handheld devices that don&#8217;t do media queries, most notably IE Mobile and Blackberry&#8217;s browser. Checkout <a href="http://www.quirksmode.org/m/css.html#t021">PPK&#8217;s compatibility table</a> to see which browser does not support Media Queries yet.</p>
<h2>Filling the gaps</h2>
<p>But this still is not enough to have your site render well in all browsers. IE and many older browsers do not handle the new media queries.</p>
<p><a href="http://www.alistapart.com/articles/return-of-the-mobile-stylesheet" target="_blank">Some sort of solution was proposed on ALA</a>, but that technique requires an extra CSS file called <code>antiscreen.css</code> that cancels some of all styles that were created in the <code>screen.css</code>. Most of the websites I make just have too much CSS styling to make that technique usable.</p>
<p>JavaScript can also detect the screen width, so I decided to use it to help browsers in choosing the right CSS. The script I created also checks the screen width after a window resize, just like Media Queries. Just open the demo and you will see that the page will switch to the mobile stylesheet if the window gets too narrow. Even in browsers that don&#8217;t support Media Queries (yes, I&#8217;m looking at you, IE!).</p>
<h2>How it works</h2>
<p>In the demo the script expects that <em>if</em> Media Queries are supported by the browser, a div with the class <code>cssLoadCheck</code> should be 100 pixels in width. To check that it this is true it will insert a div with that class into the DOM, check its width and then removes it from the DOM again. If the width of that test div isn&#8217;t 100 pixels we know that Media Queries are not supported and that JavaScript has to supply a CSS file depending on its width.</p>
<p>Each time the pages refreshes it removes the dynamically added link-tags in the head and adds new ones.</p>
<h2>Possible improvements</h2>
<p>This is just a simple script and there is lots of room for improvement. I could also built a script that figures out itself what CSS to load by looking at the media query statements in the markup. The current state of the script is good enough for my needs, so I&#8217;ll keep it like this for now.</p>


<p>Related posts:<ol><li><a href='http://www.thebrightlines.com/2010/09/27/codeview-update/' rel='bookmark' title='Permanent Link: Codeview update'>Codeview update</a></li>
<li><a href='http://www.thebrightlines.com/2011/09/29/redirect-to-a-mobile-website/' rel='bookmark' title='Permanent Link: Redirect to a mobile website'>Redirect to a mobile website</a></li>
<li><a href='http://www.thebrightlines.com/2010/05/06/new-template-for-jsdoctoolkit-codeview/' rel='bookmark' title='Permanent Link: Codeview, a new template for JSDoc Toolkit'>Codeview, a new template for JSDoc Toolkit</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2010/09/11/helping-browsers-with-media-queries/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS performance, who cares?</title>
		<link>http://www.thebrightlines.com/2010/07/28/css-performance-who-cares/</link>
		<comments>http://www.thebrightlines.com/2010/07/28/css-performance-who-cares/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 05:11:40 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Optimization]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[rendering]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=648</guid>
		<description><![CDATA[You probably didn't notice it, but the way you write CSS affects the rendering speed of the browser. Should you care about that? Most likely not, but it is possible to freeze your web page with inefficient selectors.]]></description>
			<content:encoded><![CDATA[<p>Lately I read the following text in <em>Building iPhone Apps with HTML, CSS, and JavaScript</em> (O&#8217;Reilly) on using ID&#8217;s in CSS:</p>
<blockquote cite="http://oreilly.com/catalog/9780596805784?cmp=il-orm-ofps-iphoneapps"><p>&#8220;There are differences between class and id. Class attributes should be used when you have more than one item on the page with the same class value. Conversely, id values have to be unique to a page.</p>
<p>When I first learned this, I figured I’d just always use class attributes so I wouldn’t have to worry about whether I was duping an id value. However, selecting elements by id is much faster than selecting them by class, so you can hurt your performance by overusing class selectors.&#8221;</p></blockquote>
<p>Huh? I never use ID&#8217;s in CSS selectors, but I never experienced slow rendering either. I wanted to test if it&#8217;s stupid not to use ID&#8217;s.</p>
<p>First I wanted to see if it was even able to create a CSS that was hard to parse. Google has a nice article about <a href="http://code.google.com/speed/page-speed/docs/rendering.html#UseEfficientCSSSelectors">writing efficient CSS selectors</a>, so that seemed like a good start before setting up a test. In short there are 2 things that make a fast CSS selector:</p>
<ul>
<li><strong>Make rules as specific as possible</strong><br />
This means that <code>div.content</code> is faster than <code>*</code>.<br />
You have to be especially specific with the rightmost selector, since the browser reads CSS selector from right to left.</li>
<li><strong>Avoid (large) descendant rules</strong><br />
An example of a descendant rule is <code>div.content div.column1 div.columnHeader h2</code>. Descendant rules are less efficient than rules with a single selector, like <code>h2</code>.</li>
</ul>
<h2>Test 1: setting up extremely inefficient CSS</h2>
<p>The most inefficient selector by far is <code>*</code>. Combined with large descendant rules you get extremely inefficient selectors:</p>
<pre name="code" class="css:nogutter">
* * * * * * * * * {
	background: #ff1;
}
* * * * {
	background: #ff2;
}
* * * * * * * {
	background: #ff3;
}
</pre>
<p>I created a CSS file of about 20KB in size with 3600 asterisks characters (*). I combined it with a very large HTML file (1MB) with 9000 opening HTML brackets (<). Because I only wanted to test the CSS rendering, I added the following JavaScript to be able to load the CSS file on my local computer <em>after</em> the page was loaded.</p>
<pre name="code" class="javascript:nogutter">
	<a href="javascript:loadCSS('default.css')">Load CSS</a>
	<script type="text/javascript">
		function loadCSS(url) {
			var fileref=document.createElement("link");
			fileref.setAttribute("rel", "stylesheet");
			fileref.setAttribute("type", "text/css");
			fileref.setAttribute("href", url);
			document.getElementsByTagName("head")[0].appendChild(fileref);
		}
	</script>
</pre>
<h3>Results Test 1</h3>
<table>
<thead>
<tr>
<th>Browser</th>
<th>Render time (sec)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Firefox 3.6</td>
<td>2</td>
</tr>
<tr>
<td>IE 8</td>
<td>4</td>
</tr>
<tr>
<td>IE 7</td>
<td>6</td>
</tr>
<tr>
<td>IE 6</td>
<td>11</td>
</tr>
<tr>
<td>Chrome 6</td>
<td>4</td>
</tr>
</tbody>
</table>
<p><em>All tests were done on my computer (Vista with Intel Duo Core @ 2.4GHz) except for IE7 and IE6. IE7 was tested on a Vista machine with Intel Core Duo SPU @ 2.67Ghz. IE6 was tested on my machine with Virtual PC and on a PC with Windows XP SP3 and a Pentium 3 CPU 3GHz.</em></p>
<p>The results show that browsers freeze for at least 2 seconds in order to render the CSS. So it <em>is</em> possible to screw up your rendering, but you really have to make an effort for it with large HTML files and unrealistic CSS selectors.</p>
<h2>Test 2: setting up a more realistic scenario</h2>
<p>In this test I created a more realistic scenario. I took an existing CSS file and altered it until it was 113KB in size and contained about 1050 selectors. I changed the CSS rules until the bulk of the code looked like this:</p>
<pre name="code" class="css:nogutter">
.Homepage .containerText {
	position: relative;
	margin: 15px auto 0px auto;
	width: 960px;
	background:#ffffff;
}
.Homepage .containerText .containerLeft {
	float:left;
	width:450px;
	padding:10px 20px 45px 10px;
}
.Homepage .containerText .containerLeft p {
	margin:0px 0px 5px 0px;
	color:#414a49;
	line-height:1.286em;
}
</pre>
<p>So most of the code in the CSS file consisted of descendant selectors with classes and hardly any tag names. The corresponding HTML page was also created from existing code and copy-pasted until the file was 107KB in size with almost 600 opening HTML brackets (<). Now we have a relatively large HTML and CSS, but not unrealistic. Once again I tested it in different browsers:</p>
<h3>Results Test 2</h3>
<table>
<thead>
<tr>
<th>Browser</th>
<th>Render time (sec)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Firefox 3.6</td>
<td>0</td>
</tr>
<tr>
<td>IE 8</td>
<td>0</td>
</tr>
<tr>
<td>IE 7</td>
<td>0.5</td>
</tr>
<tr>
<td>IE 6</td>
<td>1.5</td>
</tr>
<tr>
<td>Chrome 6</td>
<td>0</td>
</tr>
</tbody>
</table>
<p>All modern browsers responded so fast that I couldn&#8217;t really notice it needed rendering time. This means that the CSS file does not need any optimization by utilizing ID&#8217;s. The only browser that could profit from more efficient CSS selectors is IE 6. But since I don&#8217;t have to support IE 6 anymore, it&#8217;s not worth my time.</p>
<h2>Conclusion</h2>
<p>Writing fast CSS certainly will help some browsers on slow PC&#8217;s. But that is a minority of the users. So unless you have special requirements for your website, you&#8217;ll be better off focusing on writing logical, maintainable code than trying to get the browser to render a few milliseconds faster. There are some considerations though:</p>
<h3>Being more specific</h3>
<p>A few years ago I switched from writing <code>.foo</code> to writing <code>a.foo</code>. Adding the tag name in the selector gives me a better idea <em>what</em> I&#8217;m styling. Now I know that this coding style is also faster in rendering.</p>
<h3>Descendant selectors</h3>
<p>Descendent selectors (using more than one element in a CSS rule) are inefficient in rendering, but I won&#8217;t give that up. I like to be specific about what element I want to select in CSS. I rather write <code>div.column1 div.article span.date</code> than <code>span.date</code>. The latter is more efficient, but that only works with very small websites because only then you&#8217;d still have an overview of the all classes that are in the HTML code.</p>
<p>When I write JavaScript code I try not to &#8216;pollute&#8217; the global namespace. I try to do the same with CSS by using descendent selectors.</p>
<p>If you need faster rendering, you could alter descendant selectors by making one class that incorporates the whole path. So you&#8217;ll get <code>span.column1_article_date</code> instead of <code>div.column1 div.article span.date</code>. Although it would render faster, it also has some drawbacks. Renaming a class afterwards is tedious work, the class names can become very long and the classes can be used <em>outside</em> it&#8217;s intended containers, so a class called <code>div.column1_article_date</code> could be used anywhere in the DOM and not just inside div with the class <code>column1</code>.</p>
<h2>ID&#8217;s and JavaScript</h2>
<p>I do use ID&#8217;s by the way, Not in CSS though, but for JavaScript for these reasons:</p>
<ul>
<li>Specific elements can be easily accessed in plain JavaScript with <code>getElementById</code>.</li>
<li>If an element has an ID, I can be pretty surre that there is a bit of JavaScript attached to it.</li>
<li>Using ID&#8217;s in your jQuery selectors makes the selectors less dependent on the current HTML structure. It&#8217;s easy to break existing jQuery selectors by removing a class in the DOM.</li>
</ul>


<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>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2010/07/28/css-performance-who-cares/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Netscape and accessibility</title>
		<link>http://www.thebrightlines.com/2010/06/22/netscape-and-accessibility/</link>
		<comments>http://www.thebrightlines.com/2010/06/22/netscape-and-accessibility/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 19:43:48 +0000</pubDate>
		<dc:creator>Wouter Bos</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Usability]]></category>
		<category><![CDATA[WCAG]]></category>
		<category><![CDATA[Web development in general]]></category>
		<category><![CDATA[Netscape]]></category>
		<category><![CDATA[support]]></category>

		<guid isPermaLink="false">http://www.thebrightlines.com/?p=626</guid>
		<description><![CDATA[Lets see if an ancient browser can still handle the current web and if it's possible to help a little with the rendering of a page.]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Splash screen Netscape 4.7" src="http://www.guidebookgallery.org/pics/splashes/netscape/4.7-communicator.png" alt="" width="396" height="267" />Although we all cheer loud for all signs that proves IE6&#8217;s decline, fact is that this browser will stay to be a pain in the ass for some time. And to be honest: this is not something new. There&#8217;s always some browser lagging behind and preventing web developers of using new cool techniques. Nothing new here. Supporting Netscape in time of its final decline was also hard.</p>
<p>Yeah, Netscape 4. Now <em>that</em> was a browser that just did not want to die. Netscape wasn&#8217;t updated after 1998 but in 2001 still about 5% of the internet users used Netscape. I got curious how the web would look like in a browser that is more than a decade old. So I downloaded Netscape 4.7 and loaded some major websites to see how they would look.</p>
<p>The level of accessibility of websites varies enormously. Let&#8217;s start with one of the worse:</p>
<h2>Amazon.com</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-amazon-ns.png"><img title="Welcome to our new and improved webshop ;)" src="/article-data/images/ns-amazon-ns-small.png" alt="Welcome to our new and improved webshop ;)" width="440" height="405" /></a><p class="wp-caption-text">Welcome to our new and improved web shop <img src='http://www.thebrightlines.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p></div>
<div class="wp-caption alignnone" style="width: 450px"><img title="How the Amazon website should look like" src="/article-data/images/ns-amazon-ff-small.png" alt="How the Amazon website should look like" width="440" height="336" /><p class="wp-caption-text">How the Amazon website should look like</p></div>
<p>As you can see: Netscape renders the page but context is virtually lost. And it clearly can&#8217;t handle the sprite image in the top left corner.</p>
<h2>Twitter</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-twitter-ns.jpg"><img title="Twitter in Netscape" src="/article-data/images/ns-twitter-ns-small.jpg" alt="Twitter in Netscape" width="440" height="406" /></a><p class="wp-caption-text">A Twitter page in Netscape</p></div>
<div class="wp-caption alignnone" style="width: 450px"><a href="http://twitter.com/lyricsbylenny"><img title="How this Twitter-account should look like" src="/article-data/images/ns-twitter-ff-small.jpg" alt="How this Twitter-account should look like" width="440" height="336" /></a><p class="wp-caption-text">How this Twitter-account should look like</p></div>
<p>The lack of solid white background color in combination with a  rich-contrast background image that does get loaded is a serious  problem. Not to mention all the hidden information that becomes visible. This website too is not very usable anymore.</p>
<h2>Yahoo</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-yahoo-ns.png"><img title="Yahoo throws in a big fat warning..." src="/article-data/images/yahoo-ns-small.png" alt="Yahoo throws in a big fat warning..." width="440" height="222" /></a><p class="wp-caption-text">Yahoo just blocks you</p></div>
<p>Yahoo has another approach: It just says that you&#8217;re browser is ancient and offers download links to newer browsers.</p>
<h2>Google</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-google-ns2.png"><img title="...while Google just does its thing" src="/article-data/images/ns-google-ns2-small.png" alt="...while Google just does its thing" width="440" height="302" /></a><p class="wp-caption-text">...while Google just does it&#39;s thing</p></div>
<p>Google doesn&#8217;t complain and shows a page that looks remarkably well in Netscape 4. The links in the search results will still send you to websites that look like jigsaw puzzles, though <img src='http://www.thebrightlines.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>So you can&#8217;t browse with an ancient browser. So what?</h2>
<p>Ok, this is indeed not a drama. But think of it this way: the web is a web of <em>content</em>. Content that becomes increasingly inaccessible if you don&#8217;t rebuild its content container, the website, every few years. Most organizations do that to be up to par with the latest browsers and designs but some just have to.</p>
<h2>Help browsers with a handicap</h2>
<p>Keeping content accessible is not just a hobby. It&#8217;s a major issue for websites of (semi)government organizations for example. They have to make sure content is open to anyone. Although they focus on handicapped internet users rather than handicapped browsers, one goal remains the same: a user should be able to use a website without the need of CSS, JavaScript or any other &#8216;fancy&#8217; technique. A <code>:hover</code> is no use to a blind user, neither will color and JavaScript animation. That&#8217;s why such a person uses a different browser without such capabilities. And that&#8217;s why we have guidelines like WCAG.</p>
<p>It&#8217;s not surprising that many websites that follow WCAG guidelines or something comparable  do reasonably well in Netscape 4. I&#8217;ll repeat it again: that&#8217;s a browser from 1998.</p>
<h2>www.section508.gov</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-section508-ns.png"><img title="Unique: this website looks almost identical in Firefox and Netscape" src="/article-data/images/ns-section508-ns-small.png" alt="Unique: this website looks almost identical in Firefox and Netscape" width="440" height="405" /></a><p class="wp-caption-text">Unique: this website looks almost identical in Firefox and Netscape</p></div>
<div class="wp-caption alignnone" style="width: 450px"><img title="www.section508.gov in Firefox" src="/article-data/images/ns-section508-ff.png" alt="www.section508.gov in Firefox" width="440" height="335" /><p class="wp-caption-text">www.section508.gov in Firefox</p></div>
<p>The web design of www.section508.gov just don&#8217;t look like it stems from the 1990s, it also uses ancient techniques from that era like tables for layout, image spacers and sparse use of CSS. All big no-no&#8217;s nowadays, but the website rendering is great.</p>
<h2>Dutch web guidelines</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-webrichtlijnen-ns.png"><img title="This website is in Netscape just in black and white, but very readable." src="/article-data/images/ns-webrichtlijnen-ns-small.png" alt="This website is in Netscape just in black and white, but very readable." width="440" height="405" /></a><p class="wp-caption-text">In black and white, but ordered and readable.</p></div>
<div class="wp-caption alignnone" style="width: 450px"><img title="The same website in Firefox" src="/article-data/images/ns-webrichtlijnen-ff.png" alt="The same website in Firefox" width="440" height="335" /><p class="wp-caption-text">The same website in Firefox</p></div>
<p>The difference in rendering between Netscape and Firefox is striking. Netscape is unable to read the CSS, but that&#8217;s a good thing here. Accessibility dictates that an HTML document should be structured. So when there&#8217;s no CSS to style the document, the document structure will remain.</p>
<p>But why does Netscape not load the CSS? It appears that the media attribute link markup is key here:</p>
<pre name="code" class="xhtml:nogutter">
Netscape won't load this CSS
&lt;link rel="stylesheet" type="text/css" href="/screen.css" media="screen, tty" /&gt;

Netscape *will* load this CSS
&lt;link rel="stylesheet" type="text/css" href="/screen.css" /&gt;
</pre>
<h2>Dutch semi-governmental website (www.groenendestad.nl)</h2>
<div class="wp-caption alignnone" style="width: 450px"><a href="/article-data/images/ns-groenendestad-ns.png"><img title="The website in Netscape" src="/article-data/images/ns-groenendestad-ns-small.png" alt="The website in Netscape" width="440" height="405" /></a><p class="wp-caption-text">The website in Netscape</p></div>
<div class="wp-caption alignnone" style="width: 450px"><img title="In Firefox" src="/article-data/images/ns-groenendestad-ff.png" alt="In Firefox" width="440" height="335" /><p class="wp-caption-text">In Firefox</p></div>
<p>The last site is a semi-governmental website developed at the company I work, Estate Internet. It&#8217;s a relative new site (2 years old) but still usable in both old an new browsers.</p>
<h2>Hurdles</h2>
<p>So it <em>is</em> possible to make websites that are still usable in ancient browsers. The main obstacle is that old browsers try to render stuff like CSS and JavaScript but choke on it halfway. In case of CSS it&#8217;s possible to block Netscape by adding the <code>media</code> attribute, but that&#8217;s still a hack. Old browsers should be protected from itself. One option is to just disable everything at the client side that could harm the rendering.</p>
<p>It would be nice if you could send unsupported browsers just the HTML, while others also receive CSS and JavaScript. But browser detection can be error prone. The only stable solution I know that is easy to implement is IE version detection through conditional comments. Consider this piece of code that only gives all non-IE browsers and all IE7+ browser the site&#8217;s stylesheet.</p>
<pre>&lt;![if !IE]&gt;
    &lt;link href="css/main.css" type="text/css" /&gt;
&lt;![endif]&gt;
&lt;![if gte IE 7]&gt;
    &lt;link href="css/main.css" type="text/css" /&gt;
&lt;![endif]&gt;</pre>
<p>Conditional Comments will help us giving a soon-to-be ancient browser like IE6 the treatment it deserves <img src='http://www.thebrightlines.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Now it&#8217;s time to close Netscape again and start waiting for the new Firefox that supports basic CSS animation.</p>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://www.thebrightlines.com/2010/06/22/netscape-and-accessibility/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

