<?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>Xavisys&#187; CSS</title>
	<atom:link href="http://xavisys.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://xavisys.com</link>
	<description>WordPress Plugins and Custom WordPress Development</description>
	<lastBuildDate>Wed, 16 Nov 2011 20:45:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<atom:link rel='hub' href='http://xavisys.com/?pushpress=hub'/>
		<item>
		<title>CSS Trick: Turning a background image into a clickable link</title>
		<link>http://xavisys.com/css-trick-turning-a-background-image-into-a-clickable-link/</link>
		<comments>http://xavisys.com/css-trick-turning-a-background-image-into-a-clickable-link/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 01:32:05 +0000</pubDate>
		<dc:creator>Aaron D. Campbell</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://xavisys.com/?p=733</guid>
		<description><![CDATA[One of the things I most often get asked by people trying to master HTML and CSS is &#8220;How do I make a background image clickable?&#8221; It&#8217;s easy to wrap a regular image tag in a link, but what if your design or situation required that you use a background image? It&#8217;s actually quite simple. [...]]]></description>
			<content:encoded><![CDATA[<p>One of the things I most often get asked by people trying to master HTML and CSS is &#8220;How do I make a background image clickable?&#8221;  It&#8217;s easy to wrap a regular image tag in a link, but what if your design or situation required that you use a background image?  It&#8217;s actually quite simple.  Just follow these steps and I&#8217;ll show you how to make a clickable background image like this:</p>
<p><a href="http://xavisys.com" title="Professional WordPress Development" style="background-image:url(/wp-content/uploads/2009/11/email_logo.gif);display:block;height:58px;text-indent:-9999px;width:200px;">Xavisys Website Development</a></p>
<p><span id="more-733"></span></p>
<p>Start with just a link exactly as you would make it for any other purpose, and make sure to give the link an id so that we can use that to apply our styles:</p>
<pre class="brush: xml; title: ; notranslate">&lt;a href=&quot;http://xavisys.com&quot; title=&quot;Professional WordPress Development&quot; id=&quot;xavisys-logo&quot;&gt;Xavisys Website Development&lt;/a&gt;</pre>
<p>That&#8217;s all the (X)HTML you&#8217;ll need to make your background image clickable.  Your link should look something like this: <a href="http://xavisys.com" title="Professional WordPress Development" id="xavisys-logo">Xavisys Website Development</a></p>
<p>So, how can we make a background image a clickable link? It turns out it can be done with a clever CSS trick.  Let&#8217;s get started by adding the background image and make the link the same size as the image (so you can see the whole image).  Since an anchor tag isn&#8217;t a block level element, we need to force it to display as &#8220;block&#8221; so that we can specify the size:</p>
<pre class="brush: css; title: ; notranslate">
#xavisys-logo {
	background-image:url(/wp-content/uploads/2009/11/email_logo.gif);
	display:block;
	height:58px;
	width:200px;
}
</pre>
<p>At this point it should look something like this: <a href="http://xavisys.com" title="Professional WordPress Development" style="background-image:url(/wp-content/uploads/2009/11/email_logo.gif); width:200px; height:58px; display:block;">Xavisys Website Development</a></p>
<p>Now all we need to do is hide the text.  This can be done using &#8220;text-indent&#8221; and indenting the text completely off the screen like this:</p>
<pre class="brush: css; highlight: [5]; title: ; notranslate">
#xavisys-logo {
	background-image:url(/wp-content/uploads/2009/11/email_logo.gif);
	display:block;
	height:58px;
	text-indent:-9999px;
	width:200px;
}
</pre>
<p>And the finished product looks like this: <a href="http://xavisys.com" title="Professional WordPress Development" style="background-image:url(/wp-content/uploads/2009/11/email_logo.gif);display:block;height:58px;text-indent:-9999px;width:200px;">Xavisys Website Development</a></p>
<p>And there you have it – a quick CSS trick with clean markup that turns your background images into clickable links.  The best thing is, these don&#8217;t adversely affect your <abbr title="Search Engine Optimization">SEO</abbr> and can even be easily used inside of header tags if needed!<br />
<h3 class='related_post_title'>Related Posts:</h3>
<ul class='related_post'>
<li><a href='http://xavisys.com/becoming-a-freelance-web-developerdesigner/' title='Becoming a Freelance Web Developer/Designer'>Becoming a Freelance Web Developer/Designer</a></li>
<li><a href='http://xavisys.com/new-web-development-resource-launched/' title='New Web Development Resource Launched'>New Web Development Resource Launched</a></li>
<li><a href='http://xavisys.com/free-template-minimalist/' title='Free Template: Minimalist'>Free Template: Minimalist</a></li>
<li><a href='http://xavisys.com/free-template-bluebox/' title='Free Template: BlueBox'>Free Template: BlueBox</a></li>
<li><a href='http://xavisys.com/dilbert/' title='Dilbert'>Dilbert</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://xavisys.com/css-trick-turning-a-background-image-into-a-clickable-link/feed/</wfw:commentRss>
		<slash:comments>196</slash:comments>
		</item>
	</channel>
</rss>

