<?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 Imel on the Internet &#187; css</title>
	<atom:link href="http://ryanimel.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://ryanimel.com</link>
	<description>Entrepreneur and web developer</description>
	<lastBuildDate>Wed, 01 Sep 2010 10:28:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How I CSS</title>
		<link>http://ryanimel.com/how-i-css/</link>
		<comments>http://ryanimel.com/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/how-i-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></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>
]]></content:encoded>
			<wfw:commentRss>http://ryanimel.com/how-i-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Styling Images with CSS</title>
		<link>http://ryanimel.com/styling-images-with-css/</link>
		<comments>http://ryanimel.com/styling-images-with-css/#comments</comments>
		<pubDate>Mon, 15 Oct 2007 01:59:38 +0000</pubDate>
		<dc:creator>Ryan Imel</dc:creator>
				<category><![CDATA[Dorky Code]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[semantic markup]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.ryanimel.com/120/styling-images-with-css/</guid>
		<description><![CDATA[Maybe I&#8217;m being a bit too picky, but styling images with inline code doesn&#8217;t (always) seem like the best option. To me, it isn&#8217;t even a question of utility, such as whether inline or imported styles are the most effective &#8230; <a href="http://ryanimel.com/styling-images-with-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Maybe I&rsquo;m being a bit too picky, but styling images with inline code doesn&rsquo;t (always) seem like the best option. To me, it isn&rsquo;t even a question of utility, such as whether inline or imported styles are the most effective and easiest to use. No, it seems to be more of an issue of what is <em>correct</em> and <em>proper</em>. I question myself on this constantly, as any good semanticist should.<span id="more-120"></span> I ask myself:</p>
<ul>
<li>Where, grammatically, should this content go?</li>
<li>What markup is available that would correctly show this?</li>
<li>If necessary, how can I style this so that it appears like it seems it should?</li>
</ul>
<p>From these questions I try to find the best way to mark up content. In this way I want to look at images, most particularly images in blog posts, and see what the best way to mark them up might be.</p>
<h3>Where, grammatically, should this content go?</h3>
<p>An image is a unique form of content. There seem to be two uses for images, and I&rsquo;ll attempt to define them below.</p>
<dl>
<dt>Decorative images</dt>
<dd>Used to decorate the design of a website, usually not critical to the consumption of content</dd>
<dt>Content images</dt>
<dd>Used as a substantial source of content within the site, and usually is critical to the consumption of content</dd>
</dl>
<p>A couple of examples of what I&rsquo;m talking about:</p>
<p><img src='http://ryanimel.com/files/2007/10/cssimages_example01.jpg' alt='CSS for Images - Example 01, Church Marketing Sucks' class="main" /></p>
<p>The above screen is taken from Church Marketing Sucks, an offshoot of the Center for Church Communication, something I&rsquo;m pretty passionate about. As you can see, the background image on the site is for decoration, as is the header sweeper design. I consider these <em>decorative</em> because they could be stripped away without the content of the site going away.</p>
<p><a href="http://alistapart.com/articles/figurehandler"><img src='http://ryanimel.com/files/2007/10/cssimages_example02.jpg' alt='CSS for Images - Example 01, A List Apart' class="main" /></a></p>
<p>The above screen was taken from an article via A List Apart, which you can see by clicking either the image or <a href="http://alistapart.com/articles/figurehandler">this link</a>. Actually it&rsquo;s not a bad article&mdash;it talks about using Javascript to help with image placement, which is yet another technique. Anyway, the point of this page is that the image within the content is intended to work cooperatively <em>with</em> the content, and would detract from the message if it went away.</p>
<p>I use a different technique, depending on whether the image is intended to contribute to content <abbr title="Versus">vs.</abbr> decoration. If something is intended for decoration, I will do my best to make the image the background of a <code>div</code>. Only if the image is intended to contribute to the content (such as the <abbr title="A List Apart">ALA</abbr> example) will I use an <code>&lt;img&gt;</code> tag.</p>
<h3>What markup is available that would correctly show this?</h3>
<p>One of my pet peeves is when designers use class titles like <code>alignleft</code> and <code>alignright</code> when styling content images. The issue I have with this is the same I would have if these class names were used to name <code>div</code>s being floated to the right or the left. The problem is simple: the purpose of class names is to identify the <em>purpose</em> of the element, and not describe them according to how you will <em>style</em> them. This way, if you change the style of these elements later, they aren&rsquo;t classified incorrectly.</p>
<p>This same principle applies to content images. If content images are styled with <code>alignright</code> or <code>alignleft</code>, either by the user or a <abbr title="What You See is What You Get">WYSIWYG</abbr> editor, their positions can&rsquo;t be changed later without having awkwardly classified images.</p>
<p>I suggest three classes for content images.</p>
<ol>
<li>main</li>
<li>major</li>
<li>minor</li>
</ol>
<p>With this system, I analyzed how images could be aligned and matched them up with appropriate semantic classifications. A <strong>main</strong> image, for instance, is centered horizontally and text doesn&rsquo;t wrap around it. A <strong>major</strong> image floats to the right and wraps text to the left. A <strong>minor</strong> image floats to the left and wraps text to the right.</p>
<p>The <abbr title="Cascading Style Sheets">CSS</abbr> for the images would look like the following.</p>
<p><code><br />
img.main {<br />
margin: 0 auto 1em auto;<br />
display: block;<br />
}<br />
img.major {<br />
float: right;<br />
margin: 0 0 1em 1.5em;<br />
}<br />
img.minor {<br />
float: left;<br />
margin: 0 1.5em 1em 0;<br />
}<br />
</code></p>
<p>Then all you have to do is add <code>class=&ldquo;main&rdquo;</code> or other classes to the <code>img</code> tag and there you have it. Images with proper classifications and correct alignment that could later be changed to fit a new hierarchy or site layout.</p>
<h4>Benefits to Proper Image Classification</h4>
<ul>
<li>Uses classes correctly</li>
<li>Makes content forward&ndash;compatible</li>
<li>It&rsquo;s proper semantics</li>
</ul>
<h4>Negatives to Proper Image Classification</h4>
<ul>
<li>Won&rsquo;t work well with WYSIWYG editors</li>
<li>Requires more work/case by the user</li>
</ul>
<p>These are techniques with kinks which I&rsquo;m still working out. For instance, I still want to figure out a solid way to use this technique in conjunction with captions. I&rsquo;m addicted to Arun Kale&rsquo;s technique in <a href="http://themasterplan.in/themes/the-morning-after/">The Morning After theme</a> which I&rsquo;ve been using at Theme Playground. I&rsquo;ll post once I perfect this technique.</p>
<p>This post was initiated, in part, by Sarah over at BlueJar with her post <a href="http://www.bluejar.com/how-to-position-your-photos-and-images-using-css/">How to Position Your Photos and Images Using CSS</a>. I&rsquo;m kind of a semantics dork, so this topic caught my attention. Overall, I look forward to seeing these things develop, especially as far as valid, semantic blogging is concerned.</p>
]]></content:encoded>
			<wfw:commentRss>http://ryanimel.com/styling-images-with-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
