<?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>Productivedreams.com &#187; XHTML</title>
	<atom:link href="http://www.productivedreams.com/tag/xhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.productivedreams.com</link>
	<description>A blog to keep you updated on the latest design trends.</description>
	<lastBuildDate>Sat, 27 Mar 2010 04:09:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>IE CSS hack without using any hacks!</title>
		<link>http://www.productivedreams.com/ie-css-hack-without-using-any-hacks/</link>
		<comments>http://www.productivedreams.com/ie-css-hack-without-using-any-hacks/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 10:33:19 +0000</pubDate>
		<dc:creator>Gopal Raju</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Workshop]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Hacks]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.productivedreams.com/?p=201</guid>
		<description><![CDATA[A few days back while working for a MAJOR client (sorry, can&#8217;t mention their name), I discovered something new (I hope it&#8217;s new ) &#8211; A pure CSS based image replacement solution for IE.  This method is helpful especially to solve the PNG issue in IE6. I know there are many CSS hacks available [...]]]></description>
			<content:encoded><![CDATA[<p>A few days back while working for a MAJOR client (sorry, can&#8217;t mention their name), I discovered something new (I hope it&#8217;s new ) &#8211; A pure CSS based image replacement solution for IE.  This method is helpful especially to solve the PNG issue in IE6. I know there are many CSS hacks available out there to solve the PNG transparency issue, but this method doesn&#8217;t need any hacks!! Interesting isn&#8217;t it?</p>
<h1><strong>Step-1:</strong> Let&#8217;s review the HTML part first.</h1>
<pre class="devcodeblock" title="HTML"><table class="devcodetools"><tbody><tr><td>HTML</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">01</td><td class="devcodelinesarea"><pre class="devcode devcodeline"></pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">02</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&lt;html&gt;</pre></td></tr><tr><td class="devcodelines" width="1%">03</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">04</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&lt;head&gt;</pre></td></tr><tr><td class="devcodelines" width="1%">05</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&lt;title&gt;ProductiveDreams&lt;/title&gt;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">06</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&lt;link href=”style.css” rel=”stylesheet” type=”text/css”/&gt;</pre></td></tr><tr><td class="devcodelines" width="1%">07</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&lt;/head&gt;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">08</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines" width="1%">09</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&lt;body&gt;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">10</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&lt;div class=”bg-image”&gt;&lt;/div&gt;</pre></td></tr><tr><td class="devcodelines" width="1%">11</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&lt;/body&gt;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">12</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines" width="1%">13</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&lt;/html&gt;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">14</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline"></pre></td></tr></table></div></pre>
The following are the images that I've used for this tutorial. The image without saturation is a .gif and the colored one is a .png. You may right click and save the image.<br /><br /><div id="attachment_206" class="wp-caption alignnone" style="width: 144px"><a href="http://www.productivedreams.com/wp-content/uploads/2008/10/pd1.png"><img class="size-medium wp-image-206" title="ProductiveDreams Logo" src="http://www.productivedreams.com/wp-content/uploads/2008/10/pd1.png" alt="PNG Image" width="134" height="134" /></a><p class="wp-caption-text">Colorful PNG Image</p></div><br /><br /><div id="attachment_209" class="wp-caption alignnone" style="width: 144px"><a href="http://www.productivedreams.com/wp-content/uploads/2008/10/pd.gif"><img class="size-medium wp-image-209" title="ProductiveDreams Logo" src="http://www.productivedreams.com/wp-content/uploads/2008/10/pd.gif" alt="Desaturated GIF Image" width="134" height="134" /></a><p class="wp-caption-text">Desaturated GIF Image</p></div><br /><h1><strong>Step-2:</strong> The stylesheet</h1>
I included the following code in the stylesheet<br /><pre class="devcodeblock" title="CSS"><table class="devcodetools"><tbody><tr><td>CSS</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">01</td><td class="devcodelinesarea"><pre class="devcode devcodeline">body{</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">02</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">background:#000;</pre></td></tr><tr><td class="devcodelines" width="1%">03</td><td class="devcodelinesarea"><pre class="devcode devcodeline">text-align:center;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">04</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">}</pre></td></tr><tr><td class="devcodelines" width="1%">05</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">06</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">div.bg-image{</pre></td></tr><tr><td class="devcodelines" width="1%">07</td><td class="devcodelinesarea"><pre class="devcode devcodeline">background:transparent url(images/pd.png) no-repeat center !important;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">08</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">width:134px;</pre></td></tr><tr><td class="devcodelines" width="1%">09</td><td class="devcodelinesarea"><pre class="devcode devcodeline">height:134px;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">10</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">}</pre></td></tr></table></div></pre>
Let me walk you through the CSS. The first part simply applies a background color to the body and center aligns the div element. In the second part, I've specified the width and height of the div (134px) based on the image dimensions and have given the .png as the background image. Everything works fine?<br /><h1><strong>Step-3:</strong> Solution for IE</h1>
This the most interesting part that does the magic.<br /><br />I added another line of CSS code just below<br /><strong>background:transparent url(images/pd.png) no-repeat center !important</strong>;<br />and the following is the code<br /><strong>background-image:url(images/pd.gif);</strong><br /><br />Check out the result in IE! Awesome.... isn't it? In all other browsers except IE you will see the colorful png image.<br /><h1>Consolidating the entire thing</h1>
So. the final css would look like:<br /><pre class="devcodeblock" title="CSS"><table class="devcodetools"><tbody><tr><td>CSS</td></tr></tbody></table><div class="devcodeoverflow"><table class="devcodearea" width="100%"><tr><td class="devcodelines" width="1%">01</td><td class="devcodelinesarea"><pre class="devcode devcodeline">body{</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">02</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">background:#000;</pre></td></tr><tr><td class="devcodelines" width="1%">03</td><td class="devcodelinesarea"><pre class="devcode devcodeline">text-align:center;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">04</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">}</pre></td></tr><tr><td class="devcodelines" width="1%">05</td><td class="devcodelinesarea"><pre class="devcode devcodeline">&nbsp;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">06</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">div.bg-image{</pre></td></tr><tr><td class="devcodelines" width="1%">07</td><td class="devcodelinesarea"><pre class="devcode devcodeline">background:transparent url(images/pd.png) no-repeat center !important;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">08</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">background-image:url(images/pd.gif);</pre></td></tr><tr><td class="devcodelines" width="1%">09</td><td class="devcodelinesarea"><pre class="devcode devcodeline">width:134px;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">10</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">height:134px;</pre></td></tr><tr><td class="devcodelines" width="1%">11</td><td class="devcodelinesarea"><pre class="devcode devcodeline">margin:0px auto;</pre></td></tr><tr><td class="devcodelines devcodelinesodd" width="1%">12</td><td class="devcodelinesarea devcodelinesareaodd"><pre class="devcode devcodeline">}</pre></td></tr></table></div></pre>
<br />For your ease, I have attached the sample files as a zip. Feel free to download it <span> <img src='http://www.productivedreams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </span> and do let me know your feedbacks.<br /><br /><a class="downloadlink dlimg" href="http://www.productivedreams.com/wp-content/plugins/download-monitor/download.php?id=pd_css_solution.zip" title=" downloaded 1190 times" ><img src="" alt="Download CSS Solution for image replacement " /></a><div class="relposts"><h3>RELATED POSTS</h3><ul class="related_post"><li><a href="http://www.productivedreams.com/simple-css-based-usability-tip-for-search-buttons/" title="A simple CSS based usability tip for search buttons">A simple CSS based usability tip for search buttons</a></li><li><a href="http://www.productivedreams.com/properties-that-were-impossible-to-implement-in-ie6/" title="10 CSS properties that &#8216;were&#8217; impossible to implement in IE6">10 CSS properties that &#8216;were&#8217; impossible to implement in IE6</a></li><li><a href="http://www.productivedreams.com/min-width-issue-in-ie6/" title="Min-width issue in IE6">Min-width issue in IE6</a></li><li><a href="http://www.productivedreams.com/common-requirements-for-website-design-and-corresponding-jquery-solutions/" title="3 common requirements/issues and the corresponding Jquery solutions for your next web project">3 common requirements/issues and the corresponding Jquery solutions for your next web project</a></li><li><a href="http://www.productivedreams.com/making-gallery-submissions-easy-for-designers/" title="Making gallery submissions easy for designers">Making gallery submissions easy for designers</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://www.productivedreams.com/ie-css-hack-without-using-any-hacks/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>
