<?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>tactile &#187; Best Practices</title>
	<atom:link href="http://tactile.co.za/blog/category/best-practices/feed/" rel="self" type="application/rss+xml" />
	<link>http://tactile.co.za/blog</link>
	<description>- thoughts on CSS, UIs and UX.</description>
	<lastBuildDate>Sun, 18 Sep 2011 14:43: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>CSS Reset and &#8216;Sensible Defaults&#8217;</title>
		<link>http://tactile.co.za/blog/2010/css-reset-and-sensible-defaults/</link>
		<comments>http://tactile.co.za/blog/2010/css-reset-and-sensible-defaults/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 22:55:24 +0000</pubDate>
		<dc:creator>Shaun</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Standards]]></category>
		<category><![CDATA[code-maintenance]]></category>
		<category><![CDATA[idiocy]]></category>
		<category><![CDATA[stackoverflow]]></category>
		<category><![CDATA[teams]]></category>

		<guid isPermaLink="false">http://tactile.co.za/blog/?p=4</guid>
		<description><![CDATA[This Web Standards Drone goes down the wrong road with reset.css and comes out better for it.]]></description>
			<content:encoded><![CDATA[<p>Web Standards Advocates should really be called Zealots.  I am also guilty of punting Web Standards, sometimes with no sound reasoning behind my convictions.  This &#8216;blind faith&#8217; led me to a point where one of my team members reigned me in and showed me the misinterpretation of my ways, and it had all to do with Reset CSS and my lack of &#8216;<em>Sensible Defaults</em>&#8216;.<br />
<img src="http://tactile.co.za/blog/wp-content/uploads/2010/03/sensible.jpg" alt="" title="Roadmarkings" width="500" height="338" class="alignnone size-full wp-image-84" /></p>
<p><span id="more-4"></span></p>
<h3>CSS Reset</h3>
<p><a href="http://meyerweb.com/">Eric Meyer</a> is one of the original Web Standards Gurus.  His work is good, and pure, and great time savers for us minions.  Case in point: <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">Eric&#8217;s work on reset.css</a>.</p>
<p>What reset.css essentially does is set a common foundation in all browsers by removing the browser&#8217;s default rendering of HTML elements.  This makes it easier to author a web document so that it can look very similar in each separate browser.</p>
<h3>The problem</h3>
<p>I&#8217;ve been happily using reset.css on many projects, never noticing along the way the time I&#8217;ve spent on redefining margins on <code>&lt;ul&gt;</code> and <code>&lt;p&gt;</code> elements &#8211; time that could have been saved by defining a &#8216;<em>Sensible Default</em>&#8216;.</p>
<p>Here&#8217;s an example&#8230;</p>
<pre class="brush: css; title: ; notranslate">
ul {margin:0; padding:0; list-style:none; /*etc*/}
</pre>
<p>Reset.css would set all Unordered-Lists (<code>&lt;ul&gt;</code>) to have no margins, and no <code>list-style</code>.  This was great for defining semantic menus in the navigation and footer blocks, but&#8230;<br />
the rule would cascade! (DUH!) and each time I wanted to have default rendering of a <code>&lt;ul&gt;</code> I&#8217;d have to define it explicitly.  This situation would be exacerbated for each case when an <code>&lt;ul&gt;</code> needed to be displayed as expected, e.g. in a sidebar:</p>
<pre class="brush: css; title: ; notranslate">
#sidebar ul {margin:1em 0 1em 2em; list-style:disc;}
</pre>
<h3>The situation</h3>
<p>I started working with Christo on a Django web-app, where I basically had to handle the templates, HTML and CSS + Supporting Images.  I was using reset.css as normal.<br />
Christo started voicing his frustrations with having to rely on me to define each and every case where a paragraph was needing margins, or an unordered-list was missing its bullets.  It came down to a point where he asked me to remove reset.css.  My Standards Zeal kicked in and I refused it, saying I&#8217;d have to create more exceptions than the rule by not using reset.css.<br />
It ended up in a stalemate, so I thought I&#8217;d open up the dialogue to the <a href="http://stackoverflow.com/">StackOverflow</a> audience.  <a href="http://stackoverflow.com/questions/2281766/generic-vs-specific-element-styles-for-maintainability">I put together a quick question</a> and waited 24 hours for the answers to roll in.</p>
<h3>Enter: Sensible Defaults</h3>
<p>It turns out that the practice of defining Sensible Defaults is a common Programming tip. (This just goes to show my lack of formal programming experience!)  <a href="http://idunno.org/archive/2006/01/03/242.aspx">Defaults can save a lot of headaches</a>, and this situation of mine was no different.</p>
<h3>The solution</h3>
<p>Christo and I met half way by overriding the Reset rules just for the content area.</p>
<pre class="brush: css; title: ; notranslate">
#content ul {margin:1em 0 1em 2em; list-style:disc;}
#content p {margin:1em 0;}
/* etc */
</pre>
<p>This way I could rely on Reset.css to ease the styling of header and footer elements, and then <em>reset the reset</em> by providing default styling to any content items such as paragraphs and unordered-lists.</p>
<h3>TLDR? A warning as a conclusion</h3>
<p>So, if you want to use reset.css then please, do The Right Thing&trade;:</p>
<ul>
<li>Don&#8217;t be an idiot and implement something without understanding it</li>
<li>Define sensible defaults for where they&#8217;re needed.</li>
</ul>
<p>That is all.</p>
]]></content:encoded>
			<wfw:commentRss>http://tactile.co.za/blog/2010/css-reset-and-sensible-defaults/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

