<?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>Everything old is new again &#187; internet explorer</title>
	<atom:link href="http://www.svendtofte.com/tag/internet-explorer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.svendtofte.com</link>
	<description>rantings &#38; scraps on code and web development</description>
	<lastBuildDate>Thu, 27 Aug 2009 22:38:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The utterly retarded IE PNG implementation (and pngstrip)</title>
		<link>http://www.svendtofte.com/web/the-utterly-retarded-ie-png-implementation-and-pngstrip/</link>
		<comments>http://www.svendtofte.com/web/the-utterly-retarded-ie-png-implementation-and-pngstrip/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 19:40:07 +0000</pubDate>
		<dc:creator>Svend</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[gamma]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[png]]></category>
		<category><![CDATA[pngstrip]]></category>

		<guid isPermaLink="false">http://www.svendtofte.com/?p=117</guid>
		<description><![CDATA[pngstrip (32bit, Windows Executable at 59 kb) is a small program I&#8217;ve written to strip out the various kinds of gamma and chromacity information from PNG files. It&#8217;s written in standard ANSI C, so should compile on anything reasonable, though it has only been tested on Windows XP. The source code is also freely available. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.svendtofte.com/wp-content/uploads/2008/08/pngstrip.exe">pngstrip</a> (32bit, Windows Executable at 59 kb) is a small program I&#8217;ve written to strip out the various kinds of gamma and chromacity information from PNG files. It&#8217;s written in standard ANSI C, so should compile on anything reasonable, though it has only been tested on Windows XP. <a href="http://www.svendtofte.com/wp-content/uploads/2008/08/pngstrip.c">The source code is also freely available.</a> It&#8217;s console program, just type out <code>pngstrip filename.png</code>, and <code>filename.png</code> will be stripped.</p>
<p>We spent years <a href="http://www.alistapart.com/stories/pngopacity/">agonizing over the lack of 8-bit alpha channel in PNG in IE</a>, and when we filly get it <a href="http://blogs.msdn.com/ie/archive/2005/04/26/412263.aspx">natively/nicely supported in IE</a> they go and botch is so horribly.</p>
<p>Most of us have heard about gamma. But unless you do something in the graphics/print field, it mostly remains a button on our screen, where we tweak the luminocity of the screen. But of course, when an artist makes a snazzy PNG picture, making sure that it appears at the same display intensity as it did on his screen is understandably an laudarble goal. So PNG embeds gamma information, saying that this and that color, should be show at this and that intensity. The problem occurs when the BOG STANDARD (for 15 years and counting) HTML and CSS colors are NOT processed through the same system and thus don&#8217;t get the same gamma correction applied. <a href="http://www.svendtofte.com/wp-content/uploads/2008/08/iepng.html">The problem is easy to spot</a> (need to be viewed in IE). The PNG files, once stripped, appears correctly.</p>
<p>I won&#8217;t really bother explaining this problem more, since it goes beyond stupid, I&#8217;ll just link further reading materials if you don&#8217;t know why you may wish to strip your PNG files for gamma information. <a href="http://hsivonen.iki.fi/png-gamma/">Henri Sivonen</a> has the best treatment on the topic.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.svendtofte.com/web/the-utterly-retarded-ie-png-implementation-and-pngstrip/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IE formatting oddity</title>
		<link>http://www.svendtofte.com/stylesheets/ie-formatting-oddity/</link>
		<comments>http://www.svendtofte.com/stylesheets/ie-formatting-oddity/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 18:19:09 +0000</pubDate>
		<dc:creator>Svend</dc:creator>
				<category><![CDATA[Stylesheets]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.svendtofte.com/?p=9</guid>
		<description><![CDATA[It&#8217;s good to know that within 1 day of returning to any amount of CSS work, Internet Explorer can still baffle me. Maybe I&#8217;m missing something here, but seems that if a small tag (yes, let the damnations begin, but it was mostly due to the WordPress default template using it, that I came across [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s good to know that within 1 day of returning to any amount of CSS work, Internet Explorer can still baffle me. Maybe I&#8217;m missing something here, but seems that if a <code>small</code> tag (yes, let the damnations begin, but it was mostly due to the WordPress default template using it, that I came across it) does not include some <em>trailing whitespace</em>, it receives a little extra padding.</p>
<p class="imgWithCaption">
<img src="http://www.svendtofte.com/wp-content/uploads/2008/07/small_margin.gif" width="435" height="338" alt="Small element rendering comparison" /><br />
Rendering oddity with <code>small</code> tags with no trailing whitespace.
</p>
<p>The HTML code used validates, <a href="http://www.svendtofte.com/wp-content/uploads/2008/07/wth_ie.html">should you wish to inspect it yourself</a>. The &#8220;CSS1Compat&#8221; mode is merely to ensure we&#8217;re in &#8220;standards mode&#8221;. </p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"&gt;
&lt;head&gt;&lt;title&gt;wth ie&lt;/title&gt;
&lt;style type="text/css"&gt;
h2{
background-color:red;
margin-bottom:0;}

.wth {
background-color:green;
margin-top:0;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h2&gt;foo&lt;/h2&gt;    &lt;small class="wth"&gt; b ar &lt;/small&gt;

&lt;h2&gt;foo&lt;/h2&gt;    &lt;small class="wth"&gt; b az&lt;/small&gt;

&lt;hr/&gt;
&lt;script type="text/javascript"&gt;
document.write(document.compatMode);
&lt;/script&gt;

&lt;/body&gt;
&lt;/html&gt;</pre>
<p>You&#8217;ll notice I remove all margin on the elements. And indeed, the first header <code>h2</code> and <code>small</code> does render correctly. But the second gets a 2 pixel margin added for &#8230; who knows what reason. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.svendtofte.com/stylesheets/ie-formatting-oddity/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Reflections on max-width</title>
		<link>http://www.svendtofte.com/stylesheets/reflections-on-max-width/</link>
		<comments>http://www.svendtofte.com/stylesheets/reflections-on-max-width/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 01:52:45 +0000</pubDate>
		<dc:creator>Svend</dc:creator>
				<category><![CDATA[Stylesheets]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[internet explorer]]></category>

		<guid isPermaLink="false">http://www.svendtofte.com/?p=4</guid>
		<description><![CDATA[A couple of years ago, I added a page to my old site on an &#8220;easy&#8221; fix for emulating max-width behavior in Internet Explorer, by utilizing a powerful IE5 feature called dynamix properties/expressions.
Briefly, these expressions allow a web author to hook script expressions into the dynamic nature of HTML elements. The natural events of the [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago, I added a page to my old site on an &#8220;easy&#8221; fix for emulating max-width behavior in Internet Explorer, by utilizing a powerful IE5 feature called <a href="http://msdn.microsoft.com/en-us/library/ms537634.aspx">dynamix properties/expressions.</a></p>
<p>Briefly, these expressions allow a web author to hook script expressions into the dynamic nature of HTML elements. The natural events of the page (<code>onresize</code>, <code>onclick</code>, <code>onmouseover</code> and so on) causing these expressions to be re-evaluated whenever content could possibly reflow. The effect is naturally very powerful.</p>
<p><span id="more-4"></span></p>
<pre>&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
#container {
width:expression(this.parentElement.clientWidth-100);
background-color:red;}
&lt;/style&gt;
&lt;/head&gt;
&lt;body style="background-color:blue;"&gt;
&lt;div id="container"&gt;foo&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>The effect is unique, and should be obvious to anyone that this allows for very powerful behavior.</p>
<h3>A problem of foresight</h3>
<p>I&#8217;ll try to explain the motive for posting my old article, <a href="http://www.svendtofte.com/code/max_width_in_ie/">max-width in Internet Explorer</a>. First off, at the time I was studying alot of <a href="http://en.wikipedia.org/wiki/Human-computer_interaction"><abbr title="Human-computer interaction">HCI</abbr></a>. So while making a HTML site for a school related project, I saw a good excuse for sounding clever about line-widths. Even with most of that stuff holding true, I simply didn&#8217;t think through the ramifications of posting this &#8220;hack&#8221;. And for a large part, I simply wanted to sell the <code>expression</code> technique, as I feel it&#8217;s extremely powerful, and many developers are unfamiliar with it. So I cooked up what seemed at the time as a &#8220;elegant&#8221; solution to this max-width problem.</p>
<p>I&#8217;ve received more email about this article then anything else ever on my site (quick hit in my inbox says hundreds of mails containing <code>max-width</code>). I still receive mail about it, with IE7 supporting max-width and the related properties. So, for a very long time, I&#8217;ve wanted to &#8220;set things straight&#8221;, and I shall attempt to do this here.</p>
<h3>Not for the faint-hearted</h3>
<p>As I noted, expressions are very powerful. To fully utilize and appreciate raw expressions you <em>need</em> a solid understanding of scripting, stylesheets and how they interact in Internet Explorer, and especially you need to understand how IE works, with &#8220;<a href="http://msdn.microsoft.com/en-us/library/ms533687(VS.85).aspx">standards mode</a>&#8220;, and the <a href="http://en.wikipedia.org/wiki/Internet_Explorer_box_model_bug">old-time box-model</a>.</p>
<h4>&#8220;Houston, we have a problem&#8221;</h4>
<p>So, let&#8217;s explorer some of the problems we can run into. First off, this technique <em>may look like a style</em> in the presentation given above, but <em>it&#8217;s behavior is anything but</em>. First off, the <code>expression</code> construct used above is simply &#8220;short hand&#8221; for the <a href="http://msdn.microsoft.com/en-us/library/ms531196(VS.85).aspx"><code>setExpression</code></a> function. This means that once IE encounters the <code>expression</code> construct it <em>binds the code directly to the object</em>. If you use any fancy DOM work to disable either the entire stylesheet (stylesheet switching) or just to kill a single element, it won&#8217;t work as the expression is already bound to the actual elements. It should be easy to see in this example where <a href="http://www.svendtofte.com/wp-content/uploads/2008/07/expr_sticks.html">you can easily kill the stylesheet</a>, but observe how the <code>background-color</code> style sticks regardless.</p>
<h4>Far side of the moon</h4>
<p>Let&#8217;s examine the actual code I posted in that old article. You can see the example of <a href="http://www.svendtofte.com/wp-content/uploads/2008/07/maxwidth.html">a simulated max-width</a> here, but remember this only works in IE.</p>
<pre>&lt;html&gt;
&lt;style&gt;
body {
width:100%;
margin:0;
padding:0;}

p {
border:1px solid red;
max-width:800px;
width:expression(document.body.clientWidth &gt; 800? "800px": "auto" );
}
&lt;/style&gt;
&lt;body&gt;
&lt;p&gt;
[alot of text]
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>If you try it out in IE, it&#8217;s <em>perfect</em>. The red line is never past the view port of the browser, never does any scroll bar appear, and so on. It looks like a spot on emulation (and for this little example, it is). The code is deceptively simple, if <code>body.clientWidth</code> is more then 800 pixels wide, then we enforce a <code>width</code> of 800 pixels. Super simple and straight forward right?</p>
<p>Now, what assumptions are at work here? Well, a huge assumption is that the <code>body</code> element (or rather, the <a href="http://www.w3.org/TR/REC-CSS2/visudet.html#x0">containing box</a> of the content we wish to apply a maximum width to has no padding and/or margin. Another (more dangerous assumption) is that <em>the box model applied is the old non-standards compliant box model</em>. Another problem is that we&#8217;re working in pixels. The entire point of the article was to discuss line-lenghts. Falling back on the pixel defeats that idea. The basic problem is that it&#8217;s just so hard to retrieve information about an elements size using relative units, so I just &#8220;wing&#8221; it a bit in the article, which helps no one.</p>
<h4>Crashing hard</h4>
<p>Now, let&#8217;s see what happens when we change some of those assumptions. First off, including a proper DOCTYPE in the document causes IE to change the box model used. This will cause borders, padding, etc to not be counted towards the width of the element. This in itself isn&#8217;t so bad, it merely causes the &#8220;effect&#8221; to appear more jittery.</p>
<p>It&#8217;s far worse, if you try to apply the max-width to an element whose own width is dependent on the elements contained within. Reflowing content causes the onresize event to fire, which in turn may cause an infinite loop. <a href="http://www.svendtofte.com/wp-content/uploads/2008/07/hanging_maxwidth.html">Look at the following code same code from before</a>. <strong>WARNING: this code is designed to hang your browser if you use any older version of Internet Explorer</strong>.</p>
<pre>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;style&gt;
body {
width:100%;
margin:0;
padding:0;}

div {
background-color:green;}

p {
border:10px solid red;
padding:10px;
margin:10px;
width:expression(foo());
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="ctb"&gt;
&lt;p&gt;
&lt;script&gt;
document.write(document.compatMode);

function foo() {
	return (ctb.offsetWidth &gt; 800 ? "auto" : "800px");
}
&lt;/script&gt;
[alot of text]
&lt;/p&gt;

&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Things to note is that a <code>DOCTYPE</code> has been added, a containing box for the paragraph has been added, and some margins and padding added as well. If you attempt to run this code in IE6 (seems this has been fixed for IE7), the browser simply locks up hard, and here&#8217;s why. The paragraph will tell itself to be 800 pixels wide when the <code>ctb</code> element shrinks to any less (<code>min-width</code>). Now due to the padding and margins I&#8217;ve added, the paragraphs width will add up to 820 pixels. This will cause the <code>ctb</code> element to widen to contain it, and suddenly it&#8217;s wider then 800 pixels, and poof, the script expression thinks the width should be <code>auto</code>. The paragraph, with it&#8217;s new setting of <code>width: auto;</code> snaps down in width, to fit within the browser window, and in turn, meaning that <code>ctb</code> can size down as well, and then the whole affair just starts over. And <em>infinite loop</em>, and it locks the browser up.</p>
<p>And I think <strong>locking the browser up in this manner is about as crappily as you can treat any visitor to your site</strong>.</p>
<p>As aside, I can note that there has been some fixes to IE, to prevent the browser from hanging. First off, <em>the above code actually works in IE 7</em>. It hangs IE 6. But in order to cause it to hang, I had to swap the code out into it&#8217;s own function. If I inline the code, IE 6 just ignores the code completely, presumably using some heuristics to sniff out that this isn&#8217;t really code it wants to execute.</p>
<h3>Solutions</h3>
<p>I think the time for solutions is well past. Back in the day, Dead Edwards had a fancy HTC you could add to pages, to make IE implement all sorts of CSS properties, including max-width (seems he <a href="http://code.google.com/p/ie7-js/">continues to do this</a>). I would probably have recommended that, as that was probably a more solid drag-and-drop solution.</p>
<p>At any rate, I&#8217;ve always had a sour taste in my mouth with my old page, and I&#8217;ve tried a sort of carthasis with this post, trying to wash some of it out. I&#8217;ve never been a fan of the popular &#8220;hacks&#8221; that started to develop once Cascading Stylesheets started to catch on like wildfire. It seems to me, that relying on broken behavior in very specific versions of browsers is just stupid. It&#8217;s basicly against everything most web developers wish for when they look at a page rendering in Firefox and IE, and wish they looked the same. Refusing to accept a &#8220;blemish&#8221; on your page, and instead resorting to hacks (of which mine was admittedly the worst) to make sure your vision is presented faithfully to the visitor just smacks of arrogance to me.</p>
<p>I&#8217;ve long since stopped working at the yoke of the visual designers with photoshop files being sent my way by, and as such, I&#8217;m not entirely sure how the industry works in practise. But I sincerely hope that it has matured enough to accept imperfections, and see them for what they really are; an expression of the open nature of the web.</p>
<p>Littering our pages with browser specific hacks is no better then client sniffing code. Each time we introduce a browser specific feature on our sites, the web gets to be a little bit messier. The IE team at Microsoft has <a href="http://blogs.msdn.com/ie/archive/2008/01/21/compatibility-and-ie8.aspx">a pertinent article on what writing these browsers are like.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.svendtofte.com/stylesheets/reflections-on-max-width/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
