<?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>zahnster &#187; CSS</title>
	<atom:link href="http://zahnster.com/category/css/feed" rel="self" type="application/rss+xml" />
	<link>http://zahnster.com</link>
	<description>my name's jade. i'm a child of the internet.</description>
	<lastBuildDate>Tue, 27 Apr 2010 04:04:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Test-Driven CSS (sorta)</title>
		<link>http://zahnster.com/css/test-driven-css</link>
		<comments>http://zahnster.com/css/test-driven-css#comments</comments>
		<pubDate>Wed, 24 Dec 2008 00:07:09 +0000</pubDate>
		<dc:creator>Zahnster</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://zahnster.com/?p=112</guid>
		<description><![CDATA[A common problem that web apps face over time is CSS bloat. Especially with new sites, any rapidly-evolving app is going to be subject to some serious  front-end abuse in today&#8217;s extreme programming world. As features are added, removed, and modified on a whim, it&#8217;s all too easy for CSS to get out of [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem that web apps face over time is CSS bloat. Especially with new sites, any rapidly-evolving app is going to be subject to some serious  front-end abuse in today&#8217;s extreme programming world. As features are added, removed, and modified on a whim, it&#8217;s all too easy for CSS to get out of control.</p>
<p>This is something we&#8217;re currently faced with at Zenbe, and my current task has been to refactor our app&#8217;s CSS by finding and eliminating a decent amount of bloat that&#8217;s developed during our app&#8217;s first year (well, 8 months).</p>
<p>When starting this task, I knew that we&#8217;d have to come up with an at-a-glance method for our developers to take the newly re-factored CSS and run with it. A lot of the CSS bloat that I initially saw was related to a simple lack of consistency as new UI items have been added to our system. Take our buttons, for instance &#8211; we started off with one-size buttons, then we had 2, then we added different colors, and so on. As these items have been added, instead of letting the CSS classes build off each other<a href="#note">*</a>, we&#8217;ve acted like they&#8217;re not related at all &#8211; and before we knew it we had a ton of redundant CSS.</p>
<p>This is where test-driven CSS comes in.</p>
<p><span id="more-112"></span></p>
<div id="attachment_116" class="wp-caption alignleft" style="width: 310px"><img class="size-medium wp-image-116" title="CSS Tests" src="http://zahnster.com/wp-content/uploads/2008/12/picture-2-300x184.png" alt="Lining up UI items is a quick and easy way to build off consistencies while avoiding inconsistencies." width="300" height="184" /><p class="wp-caption-text">Lining up UI items is a quick and easy way to build off consistencies while avoiding inconsistencies.</p></div>
<p>Now, I&#8217;m not 100% sure calling this method of testing CSS &#8220;test-driven&#8221; is accurate, as you can&#8217;t really have tests for things with no true variables. Rather, the test-driven CSS I&#8217;ve created is almost like a UI element showcase. It gives us a one-stop shop for seeing our different UI items (buttons, form elements, glyphs, dialogs, etc) in their pure form &#8211; and to enable us to build new features based off what&#8217;s existing.</p>
<p>We gain some critical things by having this testing in place. First, we have a singular place where we can see all of Zenbe&#8217;s UI items in their pure form &#8211; all lined up in a row. It&#8217;s all to easy to mis-slice something by 1-2 pixels and never notice in production &#8211; it&#8217;s quite a different story when they&#8217;re all lined up next to each other. I was able to reduce nearly half of the code in our buttons.css file just by aligning the button slices so they were the same dimensions &#8211; turning any variations of these buttons into a simple background-image replacement, instead of replacing the image <em>and</em> resetting dimensions, padding, and margins.</p>
<p>Additionally, as we make changes to our code, it gives us a nice testing place so we can make sure that all of the site&#8217;s UI elements still render the way they should, which is why I&#8217;m inclined to call this &#8216;test-driven&#8217;. Additionally, the UI items are created in a tdd-like fashion: first the HTML is created, which will &#8216;fail&#8217; without the proper CSS. Then, the CSS is written so that the HTML element renders as it should.</p>
<p>As this continues to be built out I might face some unseen obstacles, but so far our pseudo test-driven CSS is going to be a huge help in keeping our CSS code mean and lean.</p>
<p><a name="note"></a><br />
<sup><em>*This concept will be covered more in an upcoming post about CSS inheritance tips</em></sup></p>
]]></content:encoded>
			<wfw:commentRss>http://zahnster.com/css/test-driven-css/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Complex CSS Management: Part I, Asset Packaging</title>
		<link>http://zahnster.com/css/complex-css-management-asset-packaging</link>
		<comments>http://zahnster.com/css/complex-css-management-asset-packaging#comments</comments>
		<pubDate>Mon, 27 Oct 2008 21:12:46 +0000</pubDate>
		<dc:creator>Zahnster</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://zahnster.com/?p=103</guid>
		<description><![CDATA[When I started at Zenbe, I was pretty excited, because I knew it meant that I would be getting my hands dirty with some complex development issues. My history in web development has been mostly creating smaller, marketing-oriented websites, where you don&#8217;t really have to worry about frequent code evolution or long-term maintenance. Once you [...]]]></description>
			<content:encoded><![CDATA[<p>When I started at Zenbe, I was pretty excited, because I knew it meant that I would be getting my hands dirty with some complex development issues. My history in web development has been mostly creating smaller, marketing-oriented websites, where you don&#8217;t really have to worry about frequent code evolution or long-term maintenance. Once you create the site, it&#8217;s up, and maybe there will be text changes here or there, but for the most part the code base (especially things like the css) are left alone.</p>
<p>But what do you do when your product is a complex web application? How do you best maintain your stylesheets when your app is constantly growing and evolving? It&#8217;s a lot more challenging than you might think, but there are several things you can do to keep your code optimized and maintainable.</p>
<p>In order to organize my thoughts, and perhaps throw some inspiration on the subject, I&#8217;m starting a series of posts each featuring a different thing you can do to best optimize and organize your css to face the challenges of a frequently evolving web application.</p>
<p><span id="more-103"></span></p>
<p>The first thing I&#8217;m going to talk about is the importance of an asset packager. It may not seem critical, but it really is, as it empowers you to create maintainable css documents.</p>
<p>For those who aren&#8217;t familiar, asset packagers allow you to combine different stylesheets into one big, compressed stylesheet. On smaller apps, it&#8217;s very common to include the entire site&#8217;s css into one file (or a very small number of files). This is good practice &#8211; performance rules state that you should minimize http requests. However, with a complex app, forcing all of your styles into one sheet can be a quick road to disaster. Once your css is above a certain number of lines (500+ in my eyes), it can become very verbose, unorganized, and difficult to maintain.</p>
<p>For bigger apps, it&#8217;s very helpful to piece apart your style rules into different files based on functionality. For instance, with Zenbe, we have many (many!) different stylesheets &#8211; we&#8217;ll have one for base styles and one for the different buttons we have. We&#8217;re not afraid to break up our css in the smallest chunks possible, because it helps our files have meaning. If there&#8217;s a style problem with a button, I know it&#8217;s in buttons.css. I don&#8217;t have to dig around for it in some obscure, 10,000+ line global stylesheet.</p>
<p>When you make the choice to break apart you css into small, manageable chunks, you&#8217;re breaking the optimization rule of minimizing http requests. Even if you use @import, each fetched stylesheet still requires an http request. So, this is bad, right?</p>
<p>Not at all, because this is where asset packages come in.</p>
<p>Originally built for Rails by Scott Becker, the <a href="http://synthesis.sbecker.net/pages/asset_packager">asset packager</a> we use for Zenbe actually compresses all of our different stylesheets into one file. It does this on the server level, so you can easily combine any number of stylesheets while only having one http request on the client level. An added benefit of the asset packager is it also strips all extra spacing, so you can use the &#8216;1 line per style&#8217; css code style without feeling guilty about whitespace and file size.</p>
<p>Asset packager isn&#8217;t just for rails, either. There&#8217;s a <a href="http://code.google.com/p/php-asset-packager/">PHP version</a> out there as well, which was inspired by the one Becker wrote. If you use a different language &#8211; check around for one in whatever you program in. It&#8217;s definitely worth it.</p>
<p>So that&#8217;s basically it for asset packages. I can&#8217;t express how important it is to use some form of this on any complex applications &#8211; nothing kills app development like trying to keep some global stylesheet organized and maintained on a complex app that&#8217;s under constant revision.</p>
]]></content:encoded>
			<wfw:commentRss>http://zahnster.com/css/complex-css-management-asset-packaging/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>You should never (hardly) ever set heights in CSS</title>
		<link>http://zahnster.com/css/you-should-never-hardly-ever-set-heights-in-css</link>
		<comments>http://zahnster.com/css/you-should-never-hardly-ever-set-heights-in-css#comments</comments>
		<pubDate>Fri, 25 Jul 2008 18:52:50 +0000</pubDate>
		<dc:creator>Zahnster</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://zahnster.com/?p=83</guid>
		<description><![CDATA[If you find yourself setting heights on elements more often than not in CSS, take a step back, because you&#8217;re (most likely) doing something wrong, and down the road you&#8217;re going to hate yourself for it.
It&#8217;s one of the more common &#8216;css design faux pas&#8217; that I have encountered as a web developer, and to [...]]]></description>
			<content:encoded><![CDATA[<p>If you find yourself setting heights on elements more often than not in CSS, take a step back, because you&#8217;re (most likely) doing something wrong, and down the road you&#8217;re going to hate yourself for it.</p>
<p>It&#8217;s one of the more common &#8216;css design faux pas&#8217; that I have encountered as a web developer, and to me just demonstrates a lack of understanding about how box model elements behave. 99% of the time heights should be left inherit &#8211; locking yourself into a height can quickly bring limitations to your site layout, provide a maintenance nightmare, and they&#8217;re almost never needed.</p>
<p>By default, an element will be as tall as the elements/content that are inside it. A few cases which might cause a container&#8217;s height to collapse are if your internal elements are floated, or if they are absolutely positioned. In both of these cases, the easy answer is to set a height on the collapsed element and forget about it. However, this isn&#8217;t really good practice, and you&#8217;re basically treating the symptoms and not the cause.</p>
<p><span id="more-83"></span></p>
<p>If you&#8217;re losing height because of floated elements &#8211; clear them, either by using an overflow property on the containing element or doing a good ol&#8217; fashioned clear div.</p>
<p>Absolutely positioned elements can be a bit trickier, since the whole point of them is to not have layout space, so heights are acceptable, however I like to use padding whenever I can, just to avoid being locked into a set height.</p>
<p>Hopefully these tricks will be useful to someone, and make CSSing a bit more flexible and fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://zahnster.com/css/you-should-never-hardly-ever-set-heights-in-css/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>All&#8217;s Not Clear for Overflows</title>
		<link>http://zahnster.com/css/alls-not-clear-for-overflows</link>
		<comments>http://zahnster.com/css/alls-not-clear-for-overflows#comments</comments>
		<pubDate>Sat, 20 Oct 2007 00:58:02 +0000</pubDate>
		<dc:creator>Zahnster</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://zahnster.com/?p=46</guid>
		<description><![CDATA[Clearing floats have always been an annoyance for us as web developers, because it requires us to use empty markup. It wouldn&#8217;t be that much of a problem, except that using floats for complex css layouts has become somewhat of an industry standard.
Not too long ago a new trick came along which had many css [...]]]></description>
			<content:encoded><![CDATA[<p>Clearing floats have always been an annoyance for us as web developers, because it requires us to use empty markup. It wouldn&#8217;t be that much of a problem, except that using floats for complex css layouts has become somewhat of an industry standard.</p>
<p>Not too long ago a new trick came along which had many css developers feeling lighthearted &#8211; a way to clear floats without markup. It was a simple, reliable css method that&#8217;s been around for ages &#8211; the overflow property. Simply by declaring this (usually to auto or hidden), you are able to extend the parent div over the floated divs, and effectively clear your divs &#8211; something you have previously needed an empty block level html element to accomplish.</p>
<p><span id="more-46"></span></p>
<p>I am afraid, however, that this trick is too good to be true. While it may work well on simpler projects, the method becomes inherently buggy whenever mixed with or around JavaScript, specifically in the Safari web browser. Additionally, it fails to clear certain divs in IE6.</p>
<p>So, when it comes to clearing floats &#8211; I&#8217;d say stick to the markup method. At least until a real solution comes along.</p>
]]></content:encoded>
			<wfw:commentRss>http://zahnster.com/css/alls-not-clear-for-overflows/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Overzealous CSS</title>
		<link>http://zahnster.com/css/overzealous-css</link>
		<comments>http://zahnster.com/css/overzealous-css#comments</comments>
		<pubDate>Wed, 10 Oct 2007 02:06:23 +0000</pubDate>
		<dc:creator>Zahnster</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://zahnster.com/?p=44</guid>
		<description><![CDATA[Css-based web design has a fundamental belief of fully separating content from presentation. We want to optimize our HTML so we have next-to-no images or structural elements which are there for presentational purposes. Our reasons for doing so are good and right &#8211; search engine optimization, accessibility, portability, and so forth &#8211; but every once [...]]]></description>
			<content:encoded><![CDATA[<p>Css-based web design has a fundamental belief of fully separating content from presentation. We want to optimize our HTML so we have next-to-no images or structural elements which are there for presentational purposes. Our reasons for doing so are good and right &#8211; search engine optimization, accessibility, portability, and so forth &#8211; but every once in a while, despite the best of intentions, we can go a bit overboard with the stuff.</p>
<p>There&#8217;s a new trend going on, one which I am sure comes from the many text-replacement css methods that have been popping up in every css book published: entire pages with absolutely no imagery. Now, I know css is all about separation of content from presentation, and that css images are easier to replace than html images&#8230; you can chat me up about it all day. Fact remains that sometimes images say more about the content than they do the presentation.</p>
<p><span id="more-44"></span></p>
<p>Case in point: logos. I&#8217;m sure clients will not be thrilled to know that their website prints without their company logo being displayed. That instead of their brand, you get some shoddy Times New Roman font (which is probably wrapped in some ugly link style). I don&#8217;t blame you for wanting to take the graphic out, I&#8217;ve been guilty of it many times in the past, but I&#8217;m seeing this trend more and more and it really should stop. Logos aren&#8217;t presentational &#8211; they are pure content and represent the company visually.</p>
<p>It&#8217;s not just logos, either. I&#8217;ve even see sites inserting story images with css, calling it through a div with the image caption. There&#8217;s a time and a place for css, but that&#8217;s not it, because part of being a true css expert is knowing when to use it, and when not to.</p>
]]></content:encoded>
			<wfw:commentRss>http://zahnster.com/css/overzealous-css/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Universal Font Sizes</title>
		<link>http://zahnster.com/css/universal-font-sizes</link>
		<comments>http://zahnster.com/css/universal-font-sizes#comments</comments>
		<pubDate>Sat, 28 Apr 2007 05:45:08 +0000</pubDate>
		<dc:creator>Zahnster</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://zahnster.com/?p=15</guid>
		<description><![CDATA[I&#8217;ve always been a big supporter of hackless CSS. 99% of the CSS problems I&#8217;ve experienced have to do with rendering order and browser assumptions &#8211; for instance, when you set a float to something in Internet Explorer, by default it does not depreciate that element to inline; however that practice is followed in Firefox [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always been a big supporter of hackless CSS. 99% of the CSS problems I&#8217;ve experienced have to do with rendering order and browser assumptions &#8211; for instance, when you set a float to something in Internet Explorer, by default it does not depreciate that element to inline; however that practice is followed in Firefox and Safari. It&#8217;s by learning these differences and putting catches in that you can successfully develop anything hack-free.</p>
<p>However, there&#8217;s one thing that I have never been able to get around without filters, and that&#8217;s font-sizes.</p>
<p>Font sizes can be called in three ways &#8211; using pixels, ems, or percentages. Setting your font-size in pixels is optimally ideal (although I could get into many fights with some of my college teachers about this) &#8211; we&#8217;re web developers, we live in pixels. We&#8217;re familiar with them, and we know how big a 10px font looks on the screen. Besides, ems and percentages are too relative to the browsers &#8211; 1em in Firefox is not the same as 1em in Safari.</p>
<p>So why not just use pixels? Well, technically you can, and it works cross-browser, cross-platform. However, there&#8217;s a catch &#8211; if you set a font size to a pixel amount in IE &#8211; it&#8217;s stuck at that size for life. Even if you adjust the font size in your browser settings. It&#8217;s a total accessibility crutch for close to 80% of the web viewing market.</p>
<p>So, if we want to develop accessible websites, what do we do? In college, I was taught to use ems, and it was all very defended: they&#8217;re fonts, after all. Set your font and get over the minor inconsistencies. It might have worked in Advanced Web, but in the Industry you have clients and designers breathing down your neck &#8211; they don&#8217;t understand why the font is slightly bigger in Safari, and they don&#8217;t like it.</p>
<p>So what do we do? The only real solution is in IE filters &#8211; sometimes they&#8217;re just a necessary evil. Luckily, the font-size problem is only in IE6 and below, so one simple star filter can allow you to set browser font-size in pixels, but in IE, use ems.</p>
<p><em>    html { font-size: 10px; }<br />
* html { font-size: .8em; }<br />
</em><br />
For the rest of your font adjustments, feel free to use percentages or ems &#8211; everything will be relative to that base font-size setting.</p>
]]></content:encoded>
			<wfw:commentRss>http://zahnster.com/css/universal-font-sizes/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
