<?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>schoberg.net &#187; CSS</title>
	<atom:link href="http://schoberg.net/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://schoberg.net</link>
	<description></description>
	<lastBuildDate>Wed, 02 May 2012 02:47:11 +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>Easy css3 transitions</title>
		<link>http://schoberg.net/2012/05/easy-css3-transitions/</link>
		<comments>http://schoberg.net/2012/05/easy-css3-transitions/#comments</comments>
		<pubDate>Wed, 02 May 2012 02:45:23 +0000</pubDate>
		<dc:creator>Jesse Schoberg</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[css3]]></category>

		<guid isPermaLink="false">http://schoberg.net/?p=278</guid>
		<description><![CDATA[You can do a lot with css3 transitions and I&#8217;m not going to get into that here. But I am going to show you a simple line of css you can start using now to add a nice smooth animation to your :hover effects. 
Now this can be altered to your needs, I&#8217;m using 0.2 [...]]]></description>
			<content:encoded><![CDATA[<p>You can do a lot with css3 transitions and I&#8217;m not going to get into that here. But I am going to show you a simple line of css you can start using now to add a nice smooth animation to your <code>:hover</code> effects. <span id="more-278"></span></p>
<p>Now this can be altered to your needs, I&#8217;m using 0.2 seconds of transition and the &#8220;ease&#8221; effect. You can <a href="http://www.w3.org/TR/css3-transitions/">pop over to w3c</a> for all the gritty on property. But in short just add this to the css of any link (or other element you have associated a <code>:hover</code> with) and BAM. Nice smooth animation in everything except for IE. (IE10 will support it but that&#8217;s not quite out as of this writing)</p>
<h2>The css3 transition code</h2>
<pre class="css">
<span class="cssProperty">-webkit-transition</span><span class="cssRest">:</span><span class="cssValue"> all .2s ease</span><span class="cssRest">;</span><span class="cssProperty">-moz-transition</span><span class="cssRest">:</span><span class="cssValue"> all .2s ease</span><span class="cssRest">;</span><span class="cssProperty">-o-transition</span><span class="cssRest">:</span><span class="cssValue"> all .2s ease</span><span class="cssRest">;</span><span class="cssProperty">-ms-transition</span><span class="cssRest">:</span><span class="cssValue"> all .2s ease</span><span class="cssRest">;</span><span class="cssProperty">transition</span><span class="cssRest">:</span><span class="cssValue"> all .2s ease</span><span class="cssRest">;</span>
</pre>
<h2>css3 transitions working example</h2>
<p>Here is a <a href="http://jsbin.com/osufas/edit#html,live">working comparison example</a> over at jsbin.</p>
]]></content:encoded>
			<wfw:commentRss>http://schoberg.net/2012/05/easy-css3-transitions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Image Bullets for Unordered Lists using CSS</title>
		<link>http://schoberg.net/2008/10/custom-image-bullets-for-unordered-lists-using-css/</link>
		<comments>http://schoberg.net/2008/10/custom-image-bullets-for-unordered-lists-using-css/#comments</comments>
		<pubDate>Thu, 02 Oct 2008 01:17:11 +0000</pubDate>
		<dc:creator>Jesse Schoberg</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[bullets]]></category>
		<category><![CDATA[lists]]></category>
		<category><![CDATA[print style]]></category>

		<guid isPermaLink="false">http://schoberg.net/?p=84</guid>
		<description><![CDATA[Unordered lists &#60;ul&#62; have become quite a staple in the modern web developer&#8217;s tool box. We&#8217;ve taken them quite far with fancy menus and the like. However, we seem to forget about styling good &#8216;ol lists! While we often put basic lists onto our sites, they do sometimes get a bit bland and it would [...]]]></description>
			<content:encoded><![CDATA[<p>Unordered lists <code>&lt;ul&gt;</code> have become quite a staple in the modern web developer&#8217;s tool box. We&#8217;ve taken them quite far with fancy menus and the like. However, we seem to forget about styling good &#8216;ol lists! While we often put basic lists onto our sites, they do sometimes get a bit bland and it would be nice to spice them up a bit. Well here comes your guide to making your lists a bit more visually stimulating using a little css.<span id="more-84"></span></p>
<h2>Example 0 (the pre basic)</h2>
<p>Before we start getting fancy with replacing our bullets with images, let me show you what you can do using <em>only</em> css changes. There is a nice property in css called <code>list-style-type</code> which can be used on unordered <code>&lt;ul&gt;</code> and ordered <code>&lt;ol&gt;</code> lists. There are a number of <a href="http://www.w3.org/TR/CSS2/generate.html#propdef-list-style-type">declarations available</a> with a range of <a href="http://www.quirksmode.org/css/lists.html">browser compatibility</a>.<a href="http://www.quirksmode.org/css/lists.html"></a></p>
<p><strong><a href="http://schoberg.net/lab/custom-image-bullets/0.html">View Example 0 Demo »</a></strong></p>
<h3>HTML</h3>
<pre class="html"><span class="htmlOtherTag">&lt;ul&gt;</span>
    <span class="htmlOtherTag">&lt;li&gt;</span>Lorem ipsum dolor sit amet<span class="htmlOtherTag">&lt;/li&gt;</span>
    <span class="htmlOtherTag">&lt;li&gt;</span>Consectetuer adipiscing elit. Etiam sollicitudin<span class="htmlOtherTag">&lt;/li&gt;</span>
    <span class="htmlOtherTag">&lt;li&gt;</span>Capibus velit. Praesent eget dui.<span class="htmlOtherTag">&lt;/li&gt;</span>
    <span class="htmlOtherTag">&lt;li&gt;</span>Duis non elit et massa ultrices vehicula.<span class="htmlOtherTag">&lt;/li&gt;</span>
    <span class="htmlOtherTag">&lt;li&gt;</span>Aliquam fermentum ipsum auctor enim.<span class="htmlOtherTag">&lt;/li&gt;</span>
<span class="htmlOtherTag">&lt;/ul&gt;</span></pre>
<h3>CSS</h3>
<pre class="css"><span class="cssSelector">ul {</span>
    <span class="cssProperty">list-style-type</span><span class="cssRest">:</span><span class="cssValue">square</span><span class="cssRest">;</span>
<span class="cssSelector">}</span></pre>
<h2>Example 1 (the basic)</h2>
<p>OK, so now you&#8217;re (sarcastically) thinking &#8220;Wow Jesse, you turned the circle bullet into a square!&#8221;. Yea, I know that wasn&#8217;t too exciting, the good stuff is on the way. I just thought it would be nice for you to be fully versed in the bullet options (Hey I called it &#8220;Example 0&#8243; didn&#8217;t I?). Now, when following the links above you may have ran across another css declaration called <code>list-style-image</code>. In <em>theory</em> this is used to do what we are trying to accomplish here: Replace the bullet with a custom image. However, in practice this CSS declaration does not work dependably across browsers. Particularly regarding exact position of the bullet image. That being said we will <em>not</em> be using this declaration, instead will be putting the image onto the <code>&lt;li&gt;</code> using the <code>background:</code> property.</p>
<p><strong><a href="http://schoberg.net/lab/custom-image-bullets/1.html">View Example 1 Demo »</a></strong></p>
<h3>CSS</h3>
<pre class="css"><span class="cssSelector">ul{</span>
    <span class="cssProperty">list-style</span><span class="cssRest">:</span><span class="cssValue">none</span><span class="cssRest">;</span>
    <span class="cssProperty">margin</span><span class="cssRest">:</span><span class="cssValue">0 0 1em 15px</span><span class="cssRest">;</span>
    <span class="cssProperty">padding</span><span class="cssRest">:</span><span class="cssValue"> 0</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">ul li{</span>
    <span class="cssProperty">line-height</span><span class="cssRest">:</span><span class="cssValue">1.3em</span><span class="cssRest">;</span>
    <span class="cssProperty">margin</span><span class="cssRest">:</span><span class="cssValue"> .25em 0</span><span class="cssRest">;</span>
    <span class="cssProperty">padding</span><span class="cssRest">:</span><span class="cssValue"> 0 0 0 15px</span><span class="cssRest">;</span>
    <span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue">url(scho-arrow.gif) no-repeat 0 7px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span></pre>
<p style="text-align:center;"><img class="size-full wp-image-91" title="custom-image-bullets" src="http://schoberg.net/wp-content/uploads/2008/10/custom-image-bullets.png" alt="Custom Image Bullets - diagram" width="359" height="168" /></p>
<p>Now to explain the CSS a bit. First the <code>&lt;ul&gt;</code>. We remove the bullets with <code>list-style:none;</code>. Next we set the <code>margin</code>. We remove any default margins set by the browsers, set the left margin to <code>15px</code> to indent the list, and set the bottom margin to <code>1em</code> to offset the entire list from the content that follows it on the page. We do this by using the CSS shorthand <code>margin:[top] [right] [bottom] [left];</code>. We then set <code>padding:0;</code> to remove any default padding set by the browsers.</p>
<p>Next we adjust the <code>&lt;li&gt;</code>. We set the <code>line-height:1.3em;</code> to give the text some vertical spacing. We then set the top and bottom <code>margin</code> to <code>.25em</code> to give the line items a bit of vertical spacing and the left and right <code>margin</code> to <code>0</code> to reset any defaults set by the browsers. Next, we set the <code>padding</code> using shorthand like we did with the <code>margin</code>. We set the top, right and bottom paddings to <code>0</code> and then set the left to <code>15px</code>. This <code>15px</code> of <code>&lt;li&gt;</code> padding intents the text to make room for the image. You will want to adjust this to a couple px more than the width of your bullet image to make room for the image and give a little extra space before the text starts. Now to keep a uniform indent, I suggest keeping the total of the <code>padding-left</code> of the <code>&lt;li&gt;</code> and the <code>margin-left</code> of the <code>&lt;ul&gt;</code> to <code>30px</code>. So if you have a smaller image you may end up setting the <code>&lt;li&gt;</code> <code>padding-left</code> to <code>10px</code> and then setting the <code>&lt;ul&gt;</code> <code>margin-left</code> to <code>20px</code>. This keeps the text indented <code>30px</code> from the left side. Finally, we declare the <code>background</code> using the following CSS shorthand: <code>background:[image url] [repeat] [image left pos] [image top pos];</code> Here you see we&#8217;ve declared the <code>background-image</code>, set it to <code>no-repeat</code>, set the left postion to <code>0</code> and then the top position to <code>7px</code>. Now, depending on the height of your bullet image and the size of your text,  you&#8217;ll likely want to adjust this top positioning to vertically center your image on the text.</p>
<h2>Example 2 (adding polish)</h2>
<p>Example 1 got us rolling with the basic idea, but has a few minor issues to work out. First of all, since we set <code>margin-bottom:1em;</code> on the <code>&lt;ul&gt;</code> it causes nested lists to have too much space between the end of a 2nd level list and the next line item of the 1st level list. To fix that, we need to set <code>bottom-margin:0;</code> to all <code>&lt;ul&gt;</code> inside of <code>&lt;li&gt;</code>. Next, there is a small bug that plagues (you guessed it) IE 6 regarding background images that we apply the <a href="http://www.communitymx.com/content/article.cfm?page=2&amp;cid=C37E0">holly hack</a> to fix. In this example, I&#8217;ve added a 2nd level list and a really long <code>&lt;li&gt;</code>. By doing this, you can see why we set the <code>line-height</code> and the top and bottom <code>margin</code> on the<code> &lt;li&gt;</code> in Example 1. Notice how the <code>&lt;li&gt;</code> that wraps still has spacing above and below it to separate it from the surrounding line items? That&#8217;s the top and bottom margin at work.</p>
<p><strong><a href="http://schoberg.net/lab/custom-image-bullets/2.html">View Example 2 Demo »</a></strong></p>
<h3>CSS &#8211; Added</h3>
<pre class="css"><span class="cssSelector">li ul{</span>
    margin-bottom:0;
<span class="cssSelector">}</span>
<span class="cssComment">/* Holly Hack to fix ie6 li bg */</span>
<span class="cssComment">/* Hides from IE-mac \*/</span>
<span class="cssSelector">* html li{</span><span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue"> 1%</span><span class="cssRest">;</span><span class="cssSelector">}</span>
<span class="cssComment">/* End hide from IE-mac */</span></pre>
<h2>Example 3 (real world example)</h2>
<p>Now that you&#8217;ve got the idea, I&#8217;m going to show you a real world example where we tweak a couple things. First, we&#8217;re going to set the 2nd level lists back to bullets instead of images. Then we&#8217;re going to drop in some print styles so that when the page is printed it shows the default bullets.  We&#8217;re doing this because most browsers do not print background images by default and our custom bullets are background images! (Try a Print Preview of Example 3 on your browser to check it out.)</p>
<p><strong><a href="http://schoberg.net/lab/custom-image-bullets/3.html">View Example 3 Demo »</a></strong></p>
<h3>CSS</h3>
<pre class="css"><span class="cssSelector">ul{</span>
    <span class="cssProperty">list-style</span><span class="cssRest">:</span><span class="cssValue">none</span><span class="cssRest">;</span>
    <span class="cssProperty">margin</span><span class="cssRest">:</span><span class="cssValue">0 0 1em 15px</span><span class="cssRest">;</span>
    <span class="cssProperty">padding</span><span class="cssRest">:</span><span class="cssValue"> 0</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">ul li{</span>
    <span class="cssProperty">line-height</span><span class="cssRest">:</span><span class="cssValue">1.3em</span><span class="cssRest">;</span>
    <span class="cssProperty">margin</span><span class="cssRest">:</span><span class="cssValue"> .25em 0</span><span class="cssRest">;</span>
    <span class="cssProperty">padding</span><span class="cssRest">:</span><span class="cssValue"> 0 0 0 15px</span><span class="cssRest">;</span>
    <span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue">url(scho-arrow.gif) no-repeat 0 4px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">li ul{</span>
    <span class="cssProperty">margin</span><span class="cssRest">:</span><span class="cssValue">0 0 0 30px</span><span class="cssRest">;</span>
    <span class="cssProperty">list-style</span><span class="cssRest">:</span><span class="cssValue">disc</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">li ul li{</span>
    padding-left:0;
    <span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue">none</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssComment">/* Holly Hack to fix ie6 li bg */</span>
<span class="cssComment">/*  Hides from IE-mac \*/</span>
<span class="cssSelector">* html li{</span><span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue"> 1%</span><span class="cssRest">;</span><span class="cssSelector">}</span>
<span class="cssComment">/* End hide from IE-mac */</span>
<span class="cssMedia">@media print{</span>
<span class="cssSelector">ul {</span>
    <span class="cssProperty">list-style</span><span class="cssRest">:</span><span class="cssValue">disc</span><span class="cssRest">;</span>
    <span class="cssProperty">margin-left</span><span class="cssRest">:</span><span class="cssValue">30px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">ul li {</span>
    <span class="cssProperty">padding-left</span><span class="cssRest">:</span><span class="cssValue">0px</span><span class="cssRest">;</span>
    <span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue">none</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssMedia">}</span> <span class="cssComment">/* end print */</span></pre>
<h2>Example 4 (getting creative)</h2>
<p>Once you get the hang of this the possibilities are really endless. In this final example I&#8217;ll throw a few more styles in there to show you what we could do with a &#8220;Yes/No&#8221; type of list. I&#8217;ve defaulted the list items to &#8220;Yes&#8221;, but then added a <code>class="no"</code> to <code>&lt;li&gt;</code> that I want to have the &#8220;No&#8221; look. This could be used in a list of product features etc. To keep the usability, I&#8217;ve even set the print styles to an open circle for the &#8220;No&#8221; items and filled circle for the &#8220;Yes&#8221;. <small>(yes/no icons from <a href="http://sweetie.sublink.ca/">sweetie</a>)</small></p>
<p><strong><a href="http://schoberg.net/lab/custom-image-bullets/4.html">View Example 4 Demo »</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://schoberg.net/2008/10/custom-image-bullets-for-unordered-lists-using-css/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ultimate Image Replacement</title>
		<link>http://schoberg.net/2008/09/ultimate-image-replacement/</link>
		<comments>http://schoberg.net/2008/09/ultimate-image-replacement/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 17:44:49 +0000</pubDate>
		<dc:creator>Jesse Schoberg</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[fir]]></category>
		<category><![CDATA[image replacement]]></category>
		<category><![CDATA[logos]]></category>
		<category><![CDATA[print style]]></category>

		<guid isPermaLink="false">http://schoberg.net/?p=38</guid>
		<description><![CDATA[What is image replacement? If you are a web developer who cares about standards you have surely come across CSS image replacement techniques. If not, you can do a bit of research on the available methods of image replacement and the original Fahrner Image Replacement (FIR). The basic idea here is to use standard html [...]]]></description>
			<content:encoded><![CDATA[<p>What is image replacement? If you are a web developer who cares about standards you have surely come across CSS image replacement techniques. If not, you can do a bit of research on the <a href="http://www.mezzoblue.com/tests/revised-image-replacement/">available methods of image replacement</a> and <a href="http://stopdesign.com/articles/replace_text/">the original Fahrner Image Replacement (FIR)</a>. The basic idea here is to use standard html markup containing text, and then replace it with an image using CSS. Using this method search engines and screen readers can understand the HTML, while at the same time your users get to see the image of the text. This is generally used when a web developer (or client) <span style="text-decoration: line-through;">needs</span> wants to use a specialized font for page headings instead of a web friendly font.<span id="more-38"></span></p>
<h2>When to use CSS image replacement</h2>
<p>The typical use of image replacement is for replacing page headings with an image of that text. While I avoid this when I can, I do <strong>promote and use this technique for site logos</strong> on almost every site I develop. As 99% of companies have logos that can not be created with web fonts, this is a real world application for image replacement that can and should be used on production web sites. Furthermore, <a href="http://mezzoblue.com/archives/2008/05/05/image_replac/">Google is OK with image replacement</a> and has confirmed it will help your search engine placement as long as you aren&#8217;t falsely representing the image.</p>
<h2>Ultimate Image Replacement (The Schoberg Method)</h2>
<p>At <a href="http://ljhost.com">LJ Host</a> we build a lot of websites, and I have toyed around with a number of different methods over the years and they all do the job to some extent. However, there are a number of caveats with some of the methods including inaccessibility to screen readers and the text being hidden when images are turned off. My method is based on the cover up method created by <a href="http://www.pixy.cz/">Petr Staníček [aka -pixy-]</a> and showcased on his site <a href="http://www.wellstyled.com/css-replace-text-by-image.html">wellstyled.com</a>. My method has added support for linking of the object (I always think it&#8217;s a good idea to link the logo to the home page), and making the text printer friendly using print sytles.</p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-58" title="Ultimate Image Replacement diagram" src="http://schoberg.net/wp-content/uploads/2008/09/layers.png" alt="" width="404" height="92" /></p>
<h2>Example 1 (the basic)</h2>
<p>In the first example I have shown the technique in it&#8217;s most simple state. Note the empty <code>&lt;span&gt;</code> tag inside the <code>&lt;a&gt;</code>. This is what allows this method to work. If css is off you see the text. If css is on but images are off, you see the text. However, if css is on and images are on, the <code>&lt;span&gt;</code> is set to the same height and width of the containing <code>&lt;a&gt;</code> and <code>&lt;h1&gt;</code> and then positioned absolutely with the logo image set as the background of the <code>&lt;span&gt;</code>. The logo then overlays the text, showing only the image of the logo, and hiding the text behind it. (Note: Your image must be fully opaque or you will see the text through it.)</p>
<p><strong><a href="http://schoberg.net/lab/ultimate-image-replacement/1.html">View Example 1 Demo »</a></strong></p>
<h3>HMTL</h3>
<pre class="html"><span class="htmlOtherTag">&lt;h1 class=<span class="htmlAttributeValue">&quot;logo&quot;</span>&gt;</span><span class="htmlAnchorTag">&lt;a href=<span class="htmlAttributeValue">&quot;/&quot;</span>&gt;</span>Company Name<span class="htmlOtherTag">&lt;span&gt;</span><span class="htmlOtherTag">&lt;/span&gt;</span><span class="htmlAnchorTag">&lt;/a&gt;</span><span class="htmlOtherTag">&lt;/h1&gt;</span>
</pre>
<h3>CSS</h3>
<pre class="css">
<span class="cssSelector">.logo {</span>
margin:0;
padding:0;
<span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue">45px</span><span class="cssRest">;</span> <span class="cssComment">/* Height of logo */</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue"> 210px</span><span class="cssRest">;</span> <span class="cssComment">/* Width of logo */</span>
<span class="cssProperty">overflow</span><span class="cssRest">:</span><span class="cssValue">hidden</span><span class="cssRest">;</span>  <span class="cssComment">/* Stops text from protruding if  H1 text is larger than logo */</span>
<span class="cssProperty">position</span><span class="cssRest">:</span><span class="cssValue">relative</span><span class="cssRest">;</span> <span class="cssComment">/*must be relative or absolute */</span>
<span class="cssSelector">}</span>
<span class="cssSelector">.logo a{</span>
<span class="cssProperty">display</span><span class="cssRest">:</span><span class="cssValue">block</span><span class="cssRest">;</span>
<span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue">100%</span><span class="cssRest">;</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue">100%</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">.logo a span{</span>
<span class="cssProperty">display</span><span class="cssRest">:</span><span class="cssValue">block</span><span class="cssRest">;</span>
<span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue">100%</span><span class="cssRest">;</span>
<span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue">100%</span><span class="cssRest">;</span>
<span class="cssProperty">position</span><span class="cssRest">:</span><span class="cssValue">absolute</span><span class="cssRest">;</span>
top:0;
left:0;
<span class="cssProperty">background</span><span class="cssRest">:</span><span class="cssValue">url(logo.gif) no-repeat left top</span><span class="cssRest">;</span>
<span class="cssProperty">cursor</span><span class="cssRest">:</span><span class="cssValue">pointer</span><span class="cssRest">;</span> <span class="cssComment">/* ie demands we reinstate the pointer cursor */</span>
<span class="cssSelector">}</span>
</pre>
<h2>Example 2 (with print styles)</h2>
<p>In example 2 we take things a bit further by adding the print styles. The print styles are essentially reverse engineering the first styles we set. Different browsers handle printing differently. By default, Internet Explorer does not show background images and Firefox does. Furthermore, depending on your logo dimensions and length of company name text, you could run into a number of issues with spacing. We alleviate all these problems by adding print styles. First, we use <code>display:none;</code> to hide the <code>&lt;span&gt;</code> which is the layer containing the logo image. Then we reset the widths and heights of the <code>&lt;h1&gt;</code> and the <code>&lt;a&gt;</code>. Finally we add some margin to the bottom of the <code>&lt;h1&gt;</code> to add some space between it and any following elements on the page for aesthetics. Compare a print preview of the Example 1 and Example 2 demos in a few different browsers to see for yourself.</p>
<p><strong><a href="http://schoberg.net/lab/ultimate-image-replacement/2.html">View Example 2 Demo »</a></strong></p>
<h3>CSS &#8211; Added</h3>
<pre class="css"><span class="cssComment">/* == Optional Print Styles =================================================
===== Put this at the end of your style sheet or in your print style sheet */</span>
<span class="cssMedia">@media print{</span>
<span class="cssSelector">.logo a span{</span>
    <span class="cssProperty">display</span><span class="cssRest">:</span><span class="cssValue">none</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssSelector">.logo, .logo a{</span>
    <span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue"> auto</span><span class="cssRest">;</span>
    <span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue">auto</span><span class="cssRest">;</span>
    text-indent:0;
    top:0;
    left:0;
<span class="cssSelector">}</span>
<span class="cssSelector">.logo{</span>
    <span class="cssProperty">margin-bottom</span><span class="cssRest">:</span><span class="cssValue">1em</span><span class="cssRest">;</span>
<span class="cssSelector">}</span>
<span class="cssMedia">}</span> <span class="cssComment">/* end print */</span></pre>
<h2>Example 3 (real world example)</h2>
<p>In the final example I&#8217;ve altered the code just a touch by setting the <code>position:absolute;</code> and defining the exact location using <code>top:</code> and <code>left:</code>. I then dropped it into a layout so you can see how it would work in a normal situation, along with some final print styles for the whole layout. (Note: If you use <code>position:absolute;</code> for the <code>h1.logo</code> you must set the containing element to <code>position:relative;</code>)</p>
<p><strong><a href="http://schoberg.net/lab/ultimate-image-replacement/3.html">View Example 3 Demo »</a></strong></p>
<h3>CSS &#8211; Tweaked</h3>
<pre class="css"><span class="cssSelector">.logo {</span>
    margin:0;
    padding:0;
    <span class="cssProperty">height</span><span class="cssRest">:</span><span class="cssValue">45px</span><span class="cssRest">;</span> <span class="cssComment">/* Height of logo */</span>
    <span class="cssProperty">width</span><span class="cssRest">:</span><span class="cssValue"> 210px</span><span class="cssRest">;</span> <span class="cssComment">/* Width of logo */</span>
    <span class="cssProperty">overflow</span><span class="cssRest">:</span><span class="cssValue">hidden</span><span class="cssRest">;</span>  <span class="cssComment">/* Stops text from protruding if  H1 text is larger than logo */</span>
    <span class="cssProperty">position</span><span class="cssRest">:</span><span class="cssValue">absolute</span><span class="cssRest">;</span> <span class="cssComment">/*must be relative or absolute */</span>
    <span class="cssProperty">top</span><span class="cssRest">:</span><span class="cssValue">25px</span><span class="cssRest">;</span>
    <span class="cssProperty">left</span><span class="cssRest">:</span><span class="cssValue">30px</span><span class="cssRest">;</span>
<span class="cssSelector">}</span></pre>
<h2>Final Notes</h2>
<p>Even though I have called it the &#8220;Ultimate&#8221; Image Replacement technique there are a couple issues to be aware of.</p>
<ol>
<li>Your image must be opaque. If you have a transparent gif or png then the text from the <code>&lt;h1&gt;</code> will show right through. So this creates a few situations where this method will not work.</li>
<li>It does require an empty<code> &lt;span&gt;</code> tag just before the closing <code>&lt;/a&gt;</code>. While this doesn&#8217;t cause any real performance issues, html purists (myself included) are never too enthused about adding extra markup that has no structural meaning. That being said, I think the cost is worth the benefit in this case.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://schoberg.net/2008/09/ultimate-image-replacement/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

