<?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>Nathan's Blog &#187; webdesign</title>
	<atom:link href="http://nathan.studiodifferent.com/tag/webdesign/feed/" rel="self" type="application/rss+xml" />
	<link>http://nathan.studiodifferent.com</link>
	<description>Wired World Wonderings</description>
	<lastBuildDate>Mon, 22 Oct 2007 16:50:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Translucent Tables with CSS</title>
		<link>http://nathan.studiodifferent.com/2006/12/11/translucent-tables-with-css/</link>
		<comments>http://nathan.studiodifferent.com/2006/12/11/translucent-tables-with-css/#comments</comments>
		<pubDate>Tue, 12 Dec 2006 05:20:42 +0000</pubDate>
		<dc:creator>nathan</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[webdesign]]></category>

		<guid isPermaLink="false">http://nathan.studiodifferent.com/2006/12/11/translucent-tables-with-css/</guid>
		<description><![CDATA[An intranet site facelift recently called for a table with a translucent background. Firefox, my preferred browser, has supported PNG&#8217;s optional alpha channel for some time &#8212; a feature that assigns an opacity to each pixel, from fully transparent to fully opaque. A quick google search revealed that Internet Explorer has offered PNG alpha support [...]]]></description>
			<content:encoded><![CDATA[<div style="float: left; margin-right: 15px;">
<img id="image80" src="http://nathan.studiodifferent.com/wp-content/uploads/2006/12/transtable-small.jpg" alt="" />
</div>
<p>An intranet site facelift recently called for a table with a translucent background. Firefox, my preferred browser, has supported PNG&#8217;s optional alpha channel for some time &mdash; a feature that assigns an opacity to each pixel, from fully transparent to fully opaque. A quick google search revealed that Internet Explorer has offered PNG alpha support since version 5.5, so I got started.<span id="more-76"></span></p>
<p>Firefox&#8217;s native support of alpha PNG&#8217;s lends itself to a pure standards-based CSS solution: <code>#table { background: url(alpha.png); }</code>. Problem solved!:</p>
<div style="text-align: center">
<img src="http://nathan.studiodifferent.com/wp-content/uploads/2006/12/translucent-firefox.jpg" alt="" />
</div>
<p>Not so fast! Internet Explorer supports PNG&#8217;s, but it does not support their alpha channel. Instead, IE displays a gray block:</p>
<div style="text-align: center">
<img src="http://nathan.studiodifferent.com/wp-content/uploads/2006/12/translucent-ie.jpg" alt="" />
</div>
<p>So the first order of business was to hide the CSS from IE6. This is where it starts to get a bit ugly, but is easily done via CSS <a href="http://www.w3.org/TR/REC-CSS2/selector.html#child-selectors">child selector</a>, since IE ignores such rules prior to version 7: <code>body &gt; #table { background: url(alpha.png); }</code>. The &#8220;body &gt;&#8221; prefix means that the CSS rule will apply to the named element #table that is a child of a body element. With IE6 ignoring the background, I was able to pursue it&#8217;s own kludgy implementation.</p>
<p>In a likely effort to <em>embrace and extend</em> web standards, Microsoft added more proprietary CSS filters to Internet Explorer 5.5. Among them was <a href="http://msdn.microsoft.com/workshop/author/filter/reference/filters/alphaimageloader.asp">AlphaImageLoader</a>, which &#8220;Displays an image within the boundaries of the object and between the object background and content&#8221;. It is this filter that offers PNG alpha support: <code>#table { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='bg-white50-1px.png', sizingMethod='scale'); }</code>. With this rule in place, IE6 is able to display the translucent background.</p>
<p>To prevent subsequent versions of Internet Explorer from redundantly applying the AlphaImageLoader, I used Internet Explorer&#8217;s <a href="http://msdn.microsoft.com/workshop/author/dhtml/overview/ccomment_ovw.asp">conditional comments</a>:</p>
<pre>
&lt;!--[if lt IE 7]&gt;
&lt;style&gt;
#table
{
  filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='bg-white50-1px.png',sizingMethod='scale');
}
&lt;/style&gt;
&lt;![endif]--&gt;
</pre>
<p>But there was still one more surprise &mdash; this filter managed to render links in the table un-clickable. This was a mystery to me until I happened upon <a href="http://allinthehead.com/retro/69/sleight-of-hand#c000380">a comment</a> on an allinthehead post from 2003. <strong>Links in the table will break unless the image is one pixel</strong>.</p>
<p>I created a <a href="http://www.studiodifferent.com/transtable">small demo page</a> (<a href="http://nathan.studiodifferent.com/wp-content/uploads/2006/12/transtable.zip">ZIP</a>) with in-line CSS to demonstrate.</p>
]]></content:encoded>
			<wfw:commentRss>http://nathan.studiodifferent.com/2006/12/11/translucent-tables-with-css/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
