<?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>Cardeo &#187; Code</title>
	<atom:link href="http://www.cardeo.ca/category/code/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cardeo.ca</link>
	<description>Ramblings on web design and social media</description>
	<lastBuildDate>Wed, 26 Oct 2011 17:58:45 +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>AnonAnon CSS Framework</title>
		<link>http://www.cardeo.ca/2011/anonanon-css-framework</link>
		<comments>http://www.cardeo.ca/2011/anonanon-css-framework#comments</comments>
		<pubDate>Sat, 16 Jul 2011 05:35:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[baseline]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[Minimal]]></category>
		<category><![CDATA[responsive]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=4063</guid>
		<description><![CDATA[A responsive CSS framework on a baseline grid Wow! It&#8217;s been too long since I&#8217;ve published a post. Sorry guys, but I&#8217;ve been working on a few new projects. The first of them is the AnonAnon CSS Framework. Does the world need another CSS framework? Probably not, but mine has a few cool features that [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cardeo.ca/2011/anonanon-css-framework"><img src="http://www.cardeo.ca/wp-content/uploads/2011/07/blog.jpg" alt="" title="blog" width="550" height="250" class="alignnone size-full wp-image-4064" /></a><br />
<span id="more-4063"></span></p>
<h4>A responsive CSS framework on a baseline grid</h4>
<p>Wow! It&#8217;s been too long since I&#8217;ve published a post. Sorry guys, but I&#8217;ve been working on a few new projects. The first of them is the <a href="http://anonanon.org">AnonAnon</a> CSS Framework. Does the world need another CSS framework? Probably not, but mine has a few cool features that you won&#8217;t find elsewhere. Here&#8217;s a list:</p>
<ul>
<li>Minimal design and lightweight code</li>
<li>Responsive for mobile</li>
<li>Built on a baseline typographic grid</li>
<li>Includes jQuery UI elements</li>
<li>10 column, fluid grid</li>
</ul>
<p>To learn more or download, please head over to <a href="http://anonanon.org">anonanon.org</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2011/anonanon-css-framework/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>520 Grid System</title>
		<link>http://www.cardeo.ca/2010/520-grid-system</link>
		<comments>http://www.cardeo.ca/2010/520-grid-system#comments</comments>
		<pubDate>Fri, 19 Nov 2010 20:01:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[Social Media]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3815</guid>
		<description><![CDATA[If you&#8217;ve dabbled in creating a custom facebook tab for your page, or tried to style a custom tab, you&#8217;ve probably found it a little frustrating. I know I&#8217;m not a fan of inline styles and the tiny window Facebook gives you to work with. But there is a solution&#8230; Facebook Page Framework Enter the [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve dabbled in <a href="http://www.cardeo.ca/2010/how-to-create-a-custom-tab-for-your-facebook-page">creating a custom facebook tab</a> for your page, or tried to <a href="http://www.cardeo.ca/2010/styling-a-custom-facebook-tab">style a custom tab</a>, you&#8217;ve probably found it a little frustrating. I know I&#8217;m not a fan of inline styles and the tiny window Facebook gives you to work with. But there is a solution&#8230;<br />
<span id="more-3815"></span></p>
<blockquote class="center"><p><img src="http://520grid.com/img/header.jpg" alt="520grid" /></p></blockquote>
<h4>Facebook Page Framework</h4>
<p>Enter the <a href="http://520grid.com/">520 Grid System</a>. The developer describes the framework as an &#8220;HTML/CSS Framework made for Facebook Page Developers and Narrow Website Templates Lovers&#8221;. Here&#8217;s a list of features:</p>
<ul>
<li>520 Grid System is 520px wide including 16px left and right margin around container.</li>
<li>It is based on 12 grids with 16px gutters with it; 12 is nice number that can be divided with 2, 3, 4 or 6 to get inline rows with equal width.</li>
<li>Built-in text, table, and form styles coming soon.</li>
</ul>
<blockquote class="center"><p><a href="http://www.facebook.com/520GridSystem?v=app_4949752878">View Demo on Facebook</a> | <a href="http://520grid.com/">Download for Free</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/520-grid-system/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Part 1: Ruby tips for beginners</title>
		<link>http://www.cardeo.ca/2010/part-1-ruby-tips-for-beginners</link>
		<comments>http://www.cardeo.ca/2010/part-1-ruby-tips-for-beginners#comments</comments>
		<pubDate>Wed, 03 Nov 2010 23:56:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[beginner]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3799</guid>
		<description><![CDATA[I published a post a few days ago about learning to program. In my post I outlined my exploration into a few scripting languages. I concluded that I was going to spend sometime learning Ruby, by taking an online course from rubylearning.org. Anyhow, I also mentioned that I would try to post some of my [...]]]></description>
			<content:encoded><![CDATA[<p>I published a post a few days ago about <a href="http://www.cardeo.ca/2010/learning-to-program-ruby">learning to program</a>. In my post I outlined my exploration into a few scripting languages. I concluded that I was going to spend sometime learning <a href="http://www.ruby-lang.org/">Ruby</a>, by taking an online course from <a href="http://rubylearning.org/">rubylearning.org</a>. Anyhow, I also mentioned that I would try to post some of my book learnings here on the blog. This post is the first in a series that will do just that. <span id="more-3799"></span></p>
<h4>Running your programs</h4>
<p>I&#8217;m going to start with the very basics here. Below you&#8217;ll find some useful tips on starting out with Ruby. I work on a MAC, so all my references will be to working on one. If you are working on a MAC, running Snow Leopard, Ruby is already installed for you. Score! If you are running a local server like <a href="http://www.mamp.info">MAMP</a> (and I suggest you do), in your htdocs directory create a new ruby directory; feel free to call it whatever you want. </p>
<blockquote><p>A note here, you don&#8217;t need to be running a local server for this to work, I just like to keep all my web files there.</p></blockquote>
<h4>Creating your first program</h4>
<p>Ok let&#8217;s create our first program. Open <a href="http://guides.macrumors.com/Terminal">Terminal</a>, navigate to your Ruby directory and create and open a new file called lesson01.rb. All Ruby files us the <strong>.rb</strong> file extension. Once the file is open, let&#8217;s write our program. Enter the below code:</p>
<pre class="highlight">
puts 'yowza'
</pre>
<p>Save the file and exit. To run the program type <strong>ruby lesson01.rb</strong> into Terminal and hit enter. You&#8217;re program should run and return the value <strong>yowza</strong>. That&#8217;s it, you&#8217;ve run your first Ruby program.</p>
<blockquote><p>You can use single or double quotes in Ruby when defining a string. However, the common best practice is to use single quotes.</p></blockquote>
<p><strong>puts</strong> is a command for inserting a string. It stands for <strong>put string</strong>. <a href="http://pine.fm/LearnToProgram/?Chapter=01">check this out</a> for more info on strings. Now that might not be very fancy, but it gives you a basic place to start.</p>
<blockquote class="center"><p><a href="http://codecanyon.net?ref=cardeo"><img src="/images/cc_468x60_v1.gif" width="468" height="60" alt="Code Canyon" /></a></p></blockquote>
<h4>Comments</h4>
<p>There&#8217;s a couple of ways to use comments in Ruby. The first is to use a <strong>#</strong> symbol for single line quotes. For a block of text, use <strong>=begin</strong> comment here <strong>=end</strong>. Note, that is case sensitive. See below for an example.</p>
<pre class="highlight">
#this is a commented out single line of text

=begin
this is a commented out
block of copy that spans
multiple lines
=end
</pre>
<h4>Returning Values</h4>
<p>In Ruby almost all values will be returned as true. If you want a value returned false, you must use one of these two keywords: <strong>false</strong> or <strong>nil</strong>.</p>
<h4>Numbers</h4>
<p>In Ruby, numbers without decimal points are integers. Numbers with decimal points are called floats. All the standard operators apply: + addition, &#8211; subtraction, * multiplication, and / division. If you divide two numbers that result in a number with a decimal, Ruby will round down to the nearest integer. For example 3 / 2 would return 1, not 1.5. To try out some of this in practice, create a new file called lesson02.rb and enter the below code:</p>
<pre class="highlight">
puts 2 + 2
puts 10 - 5
puts 10 * 10
puts 10 / 8
</pre>
<p>Save the file and exit. Now run it in terminal by entering <strong>ruby lesson02.rb</strong>. Your output should be 4, 5, 100, and 1. Note how 10 / 8 is actually 1.25, but it is rounded down to the nearest integer, which is 1.  </p>
<p>At this point, I&#8217;ll stop for day one. Hopefully that was clear and simple. If you have any questions, please feel free to leave a comment.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/part-1-ruby-tips-for-beginners/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Snippets</title>
		<link>http://www.cardeo.ca/2010/wordpress-snippets</link>
		<comments>http://www.cardeo.ca/2010/wordpress-snippets#comments</comments>
		<pubDate>Thu, 28 Oct 2010 22:42:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[snippets]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3706</guid>
		<description><![CDATA[Recently, I came across this super handy WordPress Snippets website. I&#8217;m Loving the minimal interface that gets you to the content really quickly. Some snippet highlights would be: Facebook share, Twitter share, change admin logo, and more. Make sure you check it out.]]></description>
			<content:encoded><![CDATA[<p>Recently, I came across this super handy <a href="http://wp-snippets.com/">WordPress Snippets</a> website. I&#8217;m Loving the minimal interface that gets you to the content really quickly. Some snippet highlights would be: Facebook share, Twitter share, change admin logo, and more. Make sure you check it out. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/wordpress-snippets/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Learning to program</title>
		<link>http://www.cardeo.ca/2010/learning-to-program-ruby</link>
		<comments>http://www.cardeo.ca/2010/learning-to-program-ruby#comments</comments>
		<pubDate>Wed, 27 Oct 2010 03:47:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3704</guid>
		<description><![CDATA[Lately I&#8217;ve been struggling with the decision of what programming language I would like to pick up next. The three main options I was considering where PHP, Python/Django, and Ruby/Rails. Now out of all three of those, I probably have the most experience with PHP. However, at the end of the day, I decided to [...]]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been struggling with the decision of what programming language I would like to pick up next. The three main options I was considering where PHP, Python/Django, and Ruby/Rails. Now out of all three of those, I probably have the most experience with PHP. However, at the end of the day, I decided to go the Ruby route. <span id="more-3704"></span></p>
<h4>Ruby vs Python vs PHP</h4>
<p>At <a href="http://www.yoursole.com">work</a> we run a couple websites using the python/django combo. I actually quite like django and recently read the <a href="http://amzn.to/anYja7">Django: Visual QuickPro Guide</a>. Although, I&#8217;m a django fan, I wasn&#8217;t totally sold on python and the extra sensitive syntax. </p>
<p>As far as PHP goes, I have some experience with WordPress theme design but PHP has never really sank in for me. I also recently finished reading <a href="http://amzn.to/bpOLeC">Learning PHP, MySQL, and JavaScript: A Step-By-Step Guide to Creating Dynamic Website</a>, which is an excellent read for beginners. However, it didn&#8217;t really sell me on PHP after reading. It made PHP feel overly complicated and challenging to learn. </p>
<p>What really made my mind up was, the free web-based book  <a href='http://pine.fm/LearnToProgram/'>Learn to Program, by Chris Pine</a>. This is an amazing online resource. Chris starts from the very basics and talks about programming in general. He then moves into the Ruby language and does a great job of helping the absolute beginner along. If you are interested in programming or Ruby, I would definitely recommend checking it out. </p>
<h4>Next steps</h4>
<p>Once I finally decided that Ruby was the language I wanted to concentrate on, I started to look for additional online resources. One of the better ones I found was <a href="http://rubylearning.org">rubylearning.org</a>. They have a ton of free content, but they also offer some cheap online courses. I enrolled myself in the Core Ruby Programming course that only set me back $15. The class started this week and runs till the December. As I&#8217;m going through it, I&#8217;ll post some status updates and maybe even some tutorials. </p>
<h4>Final thoughts</h4>
<p>The Ruby versus Python argument is a sensitive one. At the end of the day, both languages are great and it&#8217;s more about personal preference. I decided to go with Ruby because programers actually refer to it as really fun to work with. Also, I&#8217;m a newb when it comes to this type of programming, and Ruby looks like it is a little easier to learn. What&#8217;s your opinion? Feel free to leave a comment below. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/learning-to-program-ruby/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Zebra-striping rows and columns</title>
		<link>http://www.cardeo.ca/2010/zebra-striping-rows-and-columns</link>
		<comments>http://www.cardeo.ca/2010/zebra-striping-rows-and-columns#comments</comments>
		<pubDate>Sat, 16 Oct 2010 21:19:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[zebra-striping]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3750</guid>
		<description><![CDATA[If you&#8217;re looking for a no nonsense technique for applying zebra-striping to a table using pure CSS, you should check out this post from csswizardry.com. In the past, you would&#8217;ve had to use javascript or another scripting technique to achieve this formatting. However, this method allows for pure CSS3 code to get the zebra-striping to [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re looking for a no nonsense technique for applying zebra-striping to a table using pure CSS, you should check out <a href="http://csswizardry.com/2010/08/zebra-striping-rows-and-columns/">this post</a> from <a href="http://csswizardry.com">csswizardry.com</a>.<br />
<span id="more-3750"></span></p>
<p>In the past, you would&#8217;ve had to use javascript or another scripting technique to achieve this formatting. However, this method allows for pure CSS3 code to get the zebra-striping to work. The one small downside is the fact that it is only supported by CSS3 browsers. </p>
<h4>Work around for older browsers</h4>
<p>This method is a little code heavier, but it will work in all browsers. First things first, we need to create some styles for the alternate table rows. Check out the example:</p>
<pre class="highlight">
tr.alt {
 background: color: #ccc;
}
</pre>
<blockquote class="center"><p><a href="http://codecanyon.net?ref=cardeo"><img src="/images/cc_468x60_v1.gif" width="468" height="60" alt="Code Canyon" /></a></p></blockquote>
<p>Here&#8217;s where the code heavy portion of the technique comes into play. You need to insert the <strong>alt</strong> class on every even <strong>&lt;tr&gt;</strong> tag in your table, as shown below:</p>
<pre class="highlight">
&lt;table&gt;
 &lt;tr&gt;
  &lt;td&gt;a row&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr class=&quot;alt&quot;&gt;
  &lt;td&gt;another row&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr&gt;
  &lt;td&gt;a third row&lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr class=&quot;alt&quot;&gt;
  &lt;td&gt;a fourth row&lt;/td&gt;
 &lt;/tr&gt;
&lt;/table&gt;
</pre>
<p>That&#8217;s it, that&#8217;s all, you can view a demo <a href="/demos/zebra-stripes/">here</a>. If you want the lighter CSS3 version, check it out at: <a href="http://csswizardry.com/2010/08/zebra-striping-rows-and-columns/">csswizadry.com</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/zebra-striping-rows-and-columns/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Syntax Highlighter</title>
		<link>http://www.cardeo.ca/2010/jquery-syntax-highlighter</link>
		<comments>http://www.cardeo.ca/2010/jquery-syntax-highlighter#comments</comments>
		<pubDate>Mon, 27 Sep 2010 17:24:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[highlighter]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3632</guid>
		<description><![CDATA[If you&#8217;re looking for a nice syntax highlighter for your website or blog, you should definitely check out jQuery Syntax Highlighter by Benjamin Lupton. It&#8217;s extremely easy to implement and has some excellent built in styles for formatting your syntax. I&#8217;ve actually started implementing it here on cardeo.ca. You can check it out in action [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re looking for a nice syntax highlighter for your website or blog, you should definitely check out <a href="http://www.balupton.com/projects/jquery-syntaxhighlighter">jQuery Syntax Highlighter</a> by <a href="http://www.balupton.com">Benjamin Lupton</a>. It&#8217;s extremely easy to implement and has some excellent built in styles for formatting your syntax. I&#8217;ve actually started implementing it here on cardeo.ca. You can check it out in action on my post <a href="http://www.cardeo.ca/2010/best-practices-for-positioning-icons-with-css">Best Practices for Positioning Icons with CSS</a>. Let me know what you think. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/jquery-syntax-highlighter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQPad &#124; An iPad Web Development Framework</title>
		<link>http://www.cardeo.ca/2010/jqpad-an-ipad-web-development-framework</link>
		<comments>http://www.cardeo.ca/2010/jqpad-an-ipad-web-development-framework#comments</comments>
		<pubDate>Wed, 25 Aug 2010 17:36:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[ipad]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3441</guid>
		<description><![CDATA[jQPad is a free iPad web development framework. It&#8217;s available for download from code.google.com. Definitely worth taking a look if you are doing web development for the iPad. Developer&#8217;s Description &#8220;jQPad is an iPad web development framework which makes iPad compatible websites easy! It uses jQuery and some awesome CSS techniques. Its very easily theme-able [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/jqpad/">jQPad</a> is a free iPad web development framework. It&#8217;s available for download from <a href="http://code.google.com/p/jqpad/">code.google.com</a>. Definitely worth taking a look if you are doing web development for the iPad.<span id="more-3441"></span></p>
<h4>Developer&#8217;s Description</h4>
<p>&#8220;jQPad is an iPad web development framework which makes iPad compatible websites easy! It uses jQuery and some awesome CSS techniques. Its very easily theme-able and also has some features which makes life for iPad development so much easier!&#8221;</p>
<blockquote class="center"><p><a href="http://www.mivlox.com/ipad/">View Demo</a> | <a href="http://code.google.com/p/jqpad/">Download</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/jqpad-an-ipad-web-development-framework/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best Practices For Positioning Icons With CSS</title>
		<link>http://www.cardeo.ca/2010/best-practices-for-positioning-icons-with-css</link>
		<comments>http://www.cardeo.ca/2010/best-practices-for-positioning-icons-with-css#comments</comments>
		<pubDate>Fri, 06 Aug 2010 07:05:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[center]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[link]]></category>
		<category><![CDATA[position]]></category>
		<category><![CDATA[vertical]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3329</guid>
		<description><![CDATA[In my opinion, icons are one of the small details that help polish an excellent website. However, it can be all-for-not if they aren&#8217;t positioned properly in your layout. In this post, I&#8217;m going to outline a few best practices for positioning your icons using CSS. Download The Source Files Small Icon With Body Copy [...]]]></description>
			<content:encoded><![CDATA[<p>In my opinion, icons are one of the small details that help polish an excellent website. However, it can be all-for-not if they aren&#8217;t positioned properly in your layout. In this post, I&#8217;m going to outline a few best practices for positioning your icons using CSS. <span id="more-3329"></span></p>
<blockquote class="center"><p><a href="http://www.mediafire.com/?6j4q6j21vz5dbi0">Download The Source Files</a></p></blockquote>
<h4>Small Icon With Body Copy</h4>
<p>This is one of the most commonly messed up use of icons you&#8217;ll see out there. The web designer will simply insert the icon image code right before the text. I&#8217;d highly recommend against using this technique. Here&#8217;s an example of it:</p>
<pre class="highlight">
&lt;img src="icon.gif" /&gt;My text here
</pre>
<p><strong>Why does this suck?</strong> Because you have no control over the positioning of the icon. A better practice would be to wrap the the text in a <strong>&lt;span&gt;</strong> tag and set the icon as the background image. Also, this technique works the best when the height of the icon matches the height of the text. Therefore, go with a 16px x 16px icon. We can adjust the vertical positioning of the background image/icon if need be. Here&#8217;s what the code looks like:</p>
<h4>CSS</h4>
<pre class="highlight">
.icon {
 background: url(icon.png) 0 0 no-repeat;
 display: block;
 height: 16px;
 line-height: 16px;
 padding-left: 20px;
 margin-right: 10px;
}
</pre>
<h4>HTML</h4>
<pre class="highlight">
&lt;span class="icon"&gt;Icon text goes here&lt;/span&gt;
</pre>
<h4>Here&#8217;s What It Should Look Like</h4>
<p><img src="http://www.cardeo.ca/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-5-Aug-10-11.59.20-PM.png" alt="" title="small-icon" width="158" height="26" class="alignnone size-full wp-image-3353" /></p>
<h4>The Code Explained</h4>
<ul>
<li>We set the <strong>background</strong> property to our icon image.</li>
<li>The position is set 0 0, you shouldn&#8217;t have to tweak this, as long as your icon height matches your text height.</li>
<li>We <strong>display</strong> it as a block so the whole icon is shown.</li>
<li>The <strong>height</strong> is set to the height of our icon.</li>
<li><strong>line-height</strong> forces the text to align vertically with the icon.</li>
<li>We <strong>pad</strong> the class left 20px to leave space for the icon.</li>
<li>Then we add a <strong>margin</strong> of 10px right to create some space between the icon and the icon text.</li>
</ul>
<p>That&#8217;s it, now your icon will always appear vertically centered to your text. As well, it will have the same spacing between the icon and the icon text. </p>
<p>You can easily apply this same technique to larger icons that are combined with larger icon text. Simply tweak the height, line-height, padding, and margin to match your new icon and text sizes. </p>
<blockquote class="center"><p><a href="http://graphicriver.net?ref=cardeo"><img src="http://www.cardeo.ca/wp-content/uploads/2009/01/gr_468x60_v1.gif" alt="" title="gr_468x60_v1" width="468" height="60" class="alignnone size-full wp-image-3035" /></a></p></blockquote>
<h4>Large Icon With Body Copy</h4>
<p>Using a larger sized icon with body copy is quite similar to the above technique. We simply need to tweak some of our property values to work with the bigger icon. Let&#8217;s assume the size our larger icon is 48px x 48px. Here&#8217;s what the code looks like:</p>
<h4>CSS</h4>
<pre class="highlight">
.icon-big {
 background: url(icon-big.png) 0 0 no-repeat;
 display: block;
 height: 48px;
 line-height: 48px;
 padding-left: 50px;
 margin-right: 10px;
}
</pre>
<h4>HTML</h4>
<pre class="highlight">
&lt;span class="big-icon"&gt;Icon text goes here&lt;/span&gt;
</pre>
<h4>Here&#8217;s What It Looks Like</h4>
<p><img src="http://www.cardeo.ca/wp-content/uploads/2010/08/Screen-shot-2010-08-05-at-5-Aug-10-11.59.28-PM.png" alt="" title="large-icon" width="192" height="50" class="alignnone size-full wp-image-3354" /></p>
<h4>The Code Explained</h4>
<ul>
<li>We&#8217;ve increased the height of the class to be 48px, so it matches the height of our larger icon.</li>
<li>We&#8217;ve also added a <strong>line-height</strong> of 48px. This will force the our text to center vertically in the layout.</li>
<li>I&#8217;ve also increased our padding-left to 50px to leave enough room for the width of the new icon.</li>
</ul>
<p>It&#8217;s that easy. But what about links? Read on for an explanation of making the icon and text work as a link. </p>
<blockquote class="center"><p><a href="http://codecanyon.net?ref=cardeo"><img src="/images/cc_468x60_v1.gif" width="468" height="60" alt="Code Canyon" /></a></p></blockquote>
<h4>Adding A Link</h4>
<p>There are two ways we can do this. The first would be making the copy a link and leaving the icon an image. The second way would be to make the icon and copy all part of the link. It&#8217;s actually quite easy, it simply depends on where you place your link tag. See below for the two examples:</p>
<h4>Only The Copy Is A Link</h4>
<pre class="highlight">
&lt;span class="icon"&gt;&lt;a href="#"&gt;link copy here&lt;/a&gt;&lt;/span&gt;
</pre>
<h4>The Icon and Copy Are Both A Part Of The Same Link</h4>
<pre class="highlight">
&lt;a href="#"&gt;&lt;span class="icon"&gt;link copy here&lt;/span&gt;&lt;/a&gt;
</pre>
<p>That&#8217;s it, that&#8217;s all. This is a fairly simple technique, but it gives you way better control of the positioning of your icons. If you have any questions, please leave a comment. </p>
<blockquote class="center"><p><a href="http://www.cardeo.ca/demos/css-icons/index.html">View The Demo</a></p></blockquote>
<blockquote class="center"><p><a href="http://www.mediafire.com/?6j4q6j21vz5dbi0">Download The Source Files</a></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/best-practices-for-positioning-icons-with-css/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS3 Questions Answered</title>
		<link>http://www.cardeo.ca/2010/css3-questions-answered</link>
		<comments>http://www.cardeo.ca/2010/css3-questions-answered#comments</comments>
		<pubDate>Thu, 17 Jun 2010 07:24:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[web design]]></category>

		<guid isPermaLink="false">http://www.cardeo.ca/?p=3231</guid>
		<description><![CDATA[This is the first post in a new series that aims to help you, the reader, with your web design problems. To start it off, I&#8217;m asking you to submit any questions your might have about CSS3. Whether you&#8217;re interested in browser support, new selectors, properties, or anything else, feel free to post your question [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first post in a new series that aims to help you, the reader, with your web design problems. To start it off, I&#8217;m asking you to submit any questions your might have about CSS3. Whether you&#8217;re interested in browser support, new selectors, properties, or anything else, feel free to post your question below.<span id="more-3231"></span></p>
<h4>What&#8217;s Your Question? Hit Me!</h4>
<p>Feel free to ask anything CSS3 related. There are no stupid questions, so don&#8217;t feel intimidated to ask something you think might have a simple answer. Chances are, someone else has the same question. Simply post your question in the comments below, and I&#8217;ll reply asap. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.cardeo.ca/2010/css3-questions-answered/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

