<?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>Coffee on the Keyboard &#187; readability</title>
	<atom:link href="http://coffeeonthekeyboard.com/tag/readability/feed/" rel="self" type="application/rss+xml" />
	<link>http://coffeeonthekeyboard.com</link>
	<description>by James Socol</description>
	<lastBuildDate>Mon, 06 Feb 2012 23:33:42 +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://pubsubhubbub.appspot.com"/>		<item>
		<title>Organizing CSS</title>
		<link>http://coffeeonthekeyboard.com/organizing-css-105/</link>
		<comments>http://coffeeonthekeyboard.com/organizing-css-105/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 13:22:16 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Standards]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Front-end]]></category>
		<category><![CDATA[organization]]></category>
		<category><![CDATA[readability]]></category>

		<guid isPermaLink="false">http://coffeeonthekeyboard.com/organizing-css-105/</guid>
		<description><![CDATA[Looking at WordPress themes usually makes me cringe. It&#8217;s as if there was a memo on semantic markup and the community of WP developers didn&#8217;t get it. Some themes waste kilobytes of HTML source on something that could be achieved with 75% less markup. Some use blatantly non-compliant code. Almost none use semantic names. But [...]]]></description>
			<content:encoded><![CDATA[<p>Looking at WordPress themes usually makes me cringe. It&#8217;s as if there was a memo on semantic markup and the community of WP developers didn&#8217;t get it.</p>
<p><a href="http://themes.wordpress.net/columns/2-columns/2991/autumn-concept-10/">Some themes</a> waste kilobytes of HTML source on something that could be achieved with 75% less markup. Some use blatantly non-compliant code. Almost none use <a href="http://coffeeonthekeyboard.com/use-semantics-to-guide-design-53/" title="semantic names">semantic names</a>.</p>
<p>But what really irks me—I&#8217;ll cop to using meaningless code to make it look good—is the style of CSS that seems to be spreading: breaking up definitions into a half-dozen chunks, no line breaks, lack of organization. I think their heart is in the right place (a section for colors, so don&#8217;t have to worry about layout; a section for typography, so the precious padding is protected) but the result is a horrid mess.</p>
<p>I <a href="http://coffeeonthekeyboard.com/the-new-blog-89/" title="blame Michael Heilemann">blame Michael Heilemann</a>, the designer behind the bland and semantic-free default WordPress theme. I imagine theme developers, many just starting with HTML and CSS, started by looking at his code, and thought that was the way to do it. Then it spread like a virus.</p>
<p>Here&#8217;s an example from &#8220;Autumn Concept 1.0&#8243;:</p>
<pre>#topbar {background-color: #4b7c44;}
#footer {background-color: #4b7c44;}
#mainpicinner {height: 250px; background: «
  url(images/mainpic01.jpg) top left «
  no-repeat #fff; border: 1px solid #fff;}
/* typography */
#logo a {color: #3a4032;}
.textbkg {border-left: 4px solid #ebf0cf;}</pre>
<p class="note">(« is an inserted linebreak.)</p>
<p>Wow. Line breaks? Readability? Was this passed through a bad version of <a href="http://www.crockford.com/javascript/jsmin.html">JSMin</a>?</p>
<p>This is from the &#8220;Color Scheme&#8221; section, but the first directive for <code>#mainpicinner</code> is <code>height</code>. It also has a <code>border</code>, not just <code>border-color</code> but the whole thing. What&#8217;s the point of having sections if you proceed to ignore them immediately?</p>
<p>The rest is filled with classes like <code>cols01</code> and <code>box01</code> (while there are other <code>cols##</code>, there is no <code>box02</code>).</p>
<p>But that isn&#8217;t my real problem. My real problem is about 20 lines further down:</p>
<pre>body {position: relative; background: #1f1f1f; «
  font: 70% Verdana, Arial, Helvetica, «
  sans-serif; text-align: center; letter-spacing: 0;}
#container {float: left; display: block; width: 100%;}
#topbar {float: left; display: block; width: «
  100%; background-image: url(images/topbar.png); «
  background-position: top; background-repeat: «
  repeat-x; text-align: left; padding: 13px 0 6px 0;}
#topbar div {padding-bottom: 0;}</pre>
<p>#container is back. (As are backgrounds. Pick a spot, already!)</p>
<p>This kind of CSS is hard to read, hard to maintain, and hard to customize. Even if the initial version is perfect—which doesn&#8217;t exist—things will start to break as soon as someone opens the file. Even in this published style sheet, the <em>author</em> couldn&#8217;t decide if background images and borders belonged in &#8220;Color Scheme&#8221; or &#8220;General Styles.&#8221; What chance does a maintainer have?</p>
<p>I am, admittedly, obsessively strict with <a href="http://coffeeonthekeyboard.com/wp-content/themes/default/style.css">my style sheets</a>. I like to make very sure that every style affects only what I intend it to affect. But I never let the styles for one element single get broken into two places. Instead, what I try to do is keep similar styles in a similar order inside those blocks:</p>
<pre>blockquote.dropquote {
  float: right;  font-family: Arial, «
    Helvetica, sans-serif;
  font-size: 130%;

color: #662020;
  background-color: #ddd;
}

div.login {
  position: absolute;
  top: 0;
  left: 0;

  font-size: 80%;

  color: #fff;
}</pre>
<p>Get the idea? Within each selector, I try to keep things in the same order. I almost always keep positioning styles first and then do either typography or color. To me, this is much more readable and maintainable. If my header div is 3 pixels too wide, I don&#8217;t have to comb through all the <code>#header</code> sections. I go to <em>one</em> place and fix it.</p>
<p>I like to <a href="http://coffeeonthekeyboard.com/work-pattern-designing-web-sites-93/" title="extract the CSS order from the document order">extract the CSS order from the document order</a>. This doesn&#8217;t necessarily stay complete or strict, especially when you have classes that can be used anywhere or you&#8217;re controlling tags directly. The header styles do come <em>before</em> the content styles, though, which come <em>before</em> the footer styles. That just makes <em>sense</em>.</p>
<p>Am I the only one who can&#8217;t stand this &#8220;style&#8221; of CSS? Do you use it? Why?</p>
]]></content:encoded>
			<wfw:commentRss>http://coffeeonthekeyboard.com/organizing-css-105/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

