<?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>Ryan on the Internet &#187; how i</title>
	<atom:link href="http://ryanimel.com/tag/how-i/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryanimel.com</link>
	<description>Entrepreneur and web developer</description>
	<lastBuildDate>Wed, 11 Jan 2012 17:03:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How I CSS</title>
		<link>http://ryanimel.com/2007/how-i-css/</link>
		<comments>http://ryanimel.com/2007/how-i-css/#comments</comments>
		<pubDate>Sat, 15 Dec 2007 00:14:26 +0000</pubDate>
		<dc:creator>Ryan Imel</dc:creator>
				<category><![CDATA[Dorky Code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[how i]]></category>

		<guid isPermaLink="false">http://www.ryanimel.com/how-i-css/</guid>
		<description><![CDATA[Cascading style sheets are an essential component of the web. I remember back when they weren&#8217;t, or more accurately back when they weren&#8217;t as popular (about the time they were only being used to set font colors). Let&#8217;s just say &#8230; <a href="http://ryanimel.com/2007/how-i-css/">Continue reading <span class="meta-nav">&#8594;</span></a><div class="addthis_toolbox addthis_default_style" addthis:url='http://ryanimel.com/2007/how-i-css/' addthis:title='How I CSS' ><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Cascading style sheets are an essential component of the web. I remember back when they weren&rsquo;t, or more accurately back when they weren&rsquo;t as popular (about the time they were only being used to set font colors). Let&rsquo;s just say I&rsquo;m very happy that the web is moving toward the separation of content, style, and behavior.</p>
<p><span id="more-141"></span></p>
<p><img src='http://www.ryanimel.com/wp-content/uploads/2007/12/css.jpg' alt='CSS on paper' /></p>
<p>Today I would like to talk about style, and some of the ways I go about writing <abbr title="Cascading Style Sheets">CSS</abbr>. There are lots of methods and tips to find out there, but hopefully I can share something unique that might help you in your writing habits.</p>
<p><!--more--></p>
<h3>Importing Stylesheets</h3>
<p>One of the first things I will do in a style sheet is drop in a few imported style sheets, like this:</p>
<p><code><br />
@import url('css/typography.css');<br />
@import url('css/layout.css');<br />
</code></p>
<p>Importing style sheets keeps <abbr title="Cascading Style Sheets">CSS</abbr> trimmed and clean. I also tend to use certain styles over and over again like typography or layout styles. Usually these style sheets can be modified to a small extent to make them usable for a new site design, without having to re-do all of the same code as before.</p>
<h3>Reset.css</h3>
<p>A style sheet to reset styles initially is crucial to have. By not resetting all of the default styles on the page, you are allowing the browser to decide for itself how it should display certain elements. I tend to agree with the great <abbr title="Cascading Style Sheets">CSS</abbr> giant Eric Meyer, who has said:</p>
<blockquote cite="Eric Meyer"><p>
Elements are nothing alone. They act the way they are told&hellip;And I don&rsquo;t want anything acting like anything unless I tell it to.
</p></blockquote>
<p><a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/" rel="met colleague">Meyer&rsquo;s <code>reset.css</code></a> is the best, which is why I use it.</p>
<h3>Ems and Pixels</h3>
<p>If it were up to me everything on the web would be sized in ems. Unfortunately, it isn&rsquo;t always possible to build (what I think of as) a <em>vector</em> web just yet. Right now we&rsquo;re stuck with raster. But while there is an excuse when it comes to sizing elements and their spacing/alignment, there is no excuse for anything but ems for typography.</p>
<p>I start by defining the font size in the body element to 62.5%. This sets the base font size (1em) to 10 pixels, which is pretty easy to scale and keep track of as you go. Then, if I want 12 pixel text, I set the font size to 1.2 ems. You get the picture.</p>
<p>Clean Code</p>
<p>When it comes to the literal act of laying out code things can get pretty messy fast. I&rsquo;ve gone back and forth about the best way to do this. I used to write in this common way:</p>
<p><code><br />
div.style {<br />
&nbsp;&nbsp;font-size: 1.2em;<br />
&nbsp;&nbsp;line-height: 1.8em;<br />
&nbsp;&nbsp;margin-bottom: 1.8em;<br />
}<br />
</code></p>
<p>And that works really well. Recently, though, I&rsquo;ve been doing it this way:</p>
<p><code><br />
div.style { font-size: 1.2em; line-height: 1.8em; margin-bottom: 1.8em; }<br />
</code></p>
<p>Using this method, I find I don&rsquo;t have to scroll nearly as much, and to my eyes it looks very clean.</p>
<h3>Commenting</h3>
<p>Commenting the styles as I write them is integral and serves two distinct purposes: organizing code into appropriate sections and describing styles/decisions/hacks/anything for the purpose of being able to understand it all later.</p>
<p>I use comments to break up my code pretty simply, usually something like:</p>
<p><code><br />
/* Header */</p>
<p>/* Sidebars */</p>
<p>/* Footer */<br />
</code></p>
<p>And that works pretty well. I also use it to describe certain stylistic decisions and explain some code to myself, for the sake of my sanity later. Every once and a while I think: <q cite="Me">But I understand how this works. It isn&rsquo;t really complicated.</q> Ah, but once I walk away from it, three months later, it will be complicated. The best advice I&rsquo;ve ever heard, when it comes to commenting code, is to think of yourself looking at this three months from now: that is how someone else will look at it, and that&rsquo;s, in the end, why you want to comment (for yourself and others).</p>
<h3>What I Want to Begin to Do</h3>
<p>I am pretty good about listing my contact information, version information, <abbr title="Et Cetera">etc.</abbr> in each style sheet, but I am not very good about leaving notes about when the last edit was made. I think that would really be helpful information, especially considering how it seems I am always updating and re-editing code across many different sites/themes/blogs.</p>
<h3>Speak up</h3>
<p>Was any of this helpful? And even if it wasn&rsquo;t, point out where you disagree. And finally, what are you <em>not</em> doing that you want to be sure and <em>start</em> doing in your code?</p>
<h3>Credit</h3>
<p>I was inspired to write this post after reading <a href="http://www.thinkvitamin.com/features/design/creating-sexy-stylesheets">Creating Sexy Stylesheets</a> over at Think Vitamin. <a href="http://www.elementfusion.com/stuff-to-read2">Tim Wall at Element Fusion</a> was kind enough to point my attention there.</p>
<div class="addthis_toolbox addthis_default_style" addthis:url='http://ryanimel.com/2007/how-i-css/' addthis:title='How I CSS' ><a class="addthis_button_facebook"></a><a class="addthis_button_twitter"></a></div>]]></content:encoded>
			<wfw:commentRss>http://ryanimel.com/2007/how-i-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

