<?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>Corey Campbell &#187; CSS</title>
	<atom:link href="http://www.webmastercorey.com/category/tutorials/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webmastercorey.com</link>
	<description>Portfolio of Corey Campbell</description>
	<lastBuildDate>Wed, 22 Sep 2010 02:57:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Replace HTML Tags with Images via CSS</title>
		<link>http://www.webmastercorey.com/2010/replace-html-tags-with-images-via-css/</link>
		<comments>http://www.webmastercorey.com/2010/replace-html-tags-with-images-via-css/#comments</comments>
		<pubDate>Tue, 04 May 2010 18:57:51 +0000</pubDate>
		<dc:creator>Corey Campbell</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.webmastercorey.com/?p=262</guid>
		<description><![CDATA[In this tutorial I will be demonstrating how to replace HTML Elements and Tags with images through CSS. Why is this applicable? Suppose you are using WordPress and you want to add your logo to a theme. By default WordPress adds something like the following code: &#60;div id=&#34;headerimg&#34;&#62; &#60;h1&#62;&#60;a href=&#34;/&#34;&#62;Your Blog Name&#60;/a&#62;&#60;/h1&#62; &#60;div class=&#34;description&#34;&#62;Description&#60;/div&#62; &#60;/div&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial I will be demonstrating how to replace HTML Elements and Tags with images through CSS.</p>
<p><strong>Why is this applicable?</strong><br />
Suppose you are using <a href="http://www.wordpress.org/">WordPress</a> and you want to add your logo to a theme. By default WordPress adds something like the following code:</p>
<pre>
<div class="codesnip-container" >
<div class="html4strict codesnip" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a> <span class="kw3">id</span><span class="sy0">=</span><span class="st0">&quot;headerimg&quot;</span>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/h1.html"><span class="kw2">h1</span></a>&gt;&lt;<a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a> <span class="kw3">href</span><span class="sy0">=</span><span class="st0">&quot;/&quot;</span>&gt;</span>Your Blog Name<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/a.html"><span class="kw2">a</span></a>&gt;&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/h1.html"><span class="kw2">h1</span></a>&gt;</span>
<span class="sc2">&lt;<a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a> <span class="kw3">class</span><span class="sy0">=</span><span class="st0">&quot;description&quot;</span>&gt;</span>Description<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a>&gt;</span>
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/div.html"><span class="kw2">div</span></a>&gt;</span></div>
</div>
</pre>
<p>And instead of having <em>Your Blog Name</em> you want to have your logo. Well, you can do that all through CSS. This same technique is great for replacing plain text with images for menus.</p>
<p>First the CSS and then I&#8217;ll explain.</p>
<pre>
<div class="codesnip-container" >
<div class="css codesnip" style="font-family:monospace;"><span class="re0">#headerimg</span> h1 <span class="br0">&#123;</span>
<span class="kw1">background</span><span class="sy0">:</span><span class="kw2">url</span><span class="br0">&#40;</span><span class="st0">'images/logo.jpg'</span><span class="br0">&#41;</span> <span class="kw2">no-repeat</span> <span class="re3">0px</span> <span class="re3">0px</span><span class="sy0">;</span>
<span class="kw1">display</span><span class="sy0">:</span> <span class="kw2">block</span><span class="sy0">;</span>
<span class="kw1">height</span><span class="sy0">:</span> <span class="re3">0px</span><span class="sy0">;</span>
<span class="kw1">padding-top</span><span class="sy0">:</span> <span class="re3">40px</span><span class="sy0">;</span>
<span class="kw1">overflow</span><span class="sy0">:</span> <span class="kw2">hidden</span><span class="sy0">;</span>
<span class="kw1">width</span><span class="sy0">:</span> <span class="re3">220px</span>
<span class="br0">&#125;</span></div>
</div>
</pre>
<p><strong>The Explanation</strong><br />
So in order to do this all through CSS we need to add a background image that is aligned to the top left or <strong>0px 0px</strong>.  We want this image to be displaying as a <strong>block</strong> so that we can mess with the height and width. The height we are setting to <strong>0px</strong> because we do not want to have the words <em>Your Blog Name</em> to be showing up on top of our logo. Instead we will use <strong>padding</strong> to change the height of the container to the size of our logo image. Make sure to make the <strong>overflow</strong> set to <strong>hidden</strong> so that the blog title does not show up underneath.</p>
<p><strong>Why not just add an image?</strong><br />
Images are great and all, but this way is helpful for search engines and browsers without CSS support. When CSS is disabled or not read the words <em>Your Blog Name</em> still appear in both search engines and CSS disabled browsers. You could use the <strong>alt</strong> tag to put the name of your title in, but when images are not displayed the typographical hierarchy is lost.</p>
<p>Well that it for this tutorial. I&#8217;ll hopefully be adding an addition to this later on for CSS menus that will include rollover states.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webmastercorey.com/2010/replace-html-tags-with-images-via-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

