<?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>HTML + CSS + JavaScript &#187; CSS</title>
	<atom:link href="http://htmlcssjavascript.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://htmlcssjavascript.com</link>
	<description>Not a Ninja, Pirate or Jedi.</description>
	<lastBuildDate>Wed, 11 Jan 2012 18:18:30 +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>Using CSS zoom and CSS Transforms For a Better &#8220;Increase Text Size&#8221; Button</title>
		<link>http://htmlcssjavascript.com/css/using-css-zoom-and-css-transforms-for-a-better-increase-text-size-button/</link>
		<comments>http://htmlcssjavascript.com/css/using-css-zoom-and-css-transforms-for-a-better-increase-text-size-button/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 19:48:22 +0000</pubDate>
		<dc:creator>Rob Larsen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[accessibility]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[chrome]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[modernizr]]></category>
		<category><![CDATA[my-work]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://htmlcssjavascript.com/?p=7817</guid>
		<description><![CDATA[So&#8230; the site I&#8217;m working on has one of those &#8220;increase text size&#8221; controls. On this project it&#8217;s turned out to be one of those features that shows up in comps and somehow falls through the cracks until later on in the project cycle. Situation normal, really, as it isn&#8217;t a big feature. It&#8217;s just [...]]]></description>
			<content:encoded><![CDATA[<p>So&#8230; the site I&#8217;m working on has one of those &#8220;increase text size&#8221; controls. On this project it&#8217;s turned out to be one of those features that shows up in comps and somehow falls through the cracks until later on in the project cycle. Situation normal, really, as it isn&#8217;t a big feature. It&#8217;s just one of those things that needs to be buttoned up before the site can go live.</p>
<p>Anyway, I was thinking about how to do implement it the other day. I haven&#8217;t done one of these in a long time and the only other time I did one it involved crafting separate, albeit small, style sheets for the larger text sizes. I didn&#8217;t want to go that way again. Basically, I just didn&#8217;t want to write new style sheets- even small ones.  </p>
<p>What&#8217;s a fella to do?</p>
<h2>zoom</h2>
<p>So, thinking about it a little bit, I seized upon using the non-standard CSS <code>zoom</code> property. Supported in Internet Explorer (<code>zoom:1</code> is often used for a <a href="http://www.satzansatz.de/cssd/onhavinglayout.html">hasLayout</a> toggle) and Webkit browsers, it would represent a simple (1 line!) CSS solution to this problem. It&#8217;s also one that I like better aesthetically as the site looks the same, just bigger. I figure there&#8217;s a reason all browsers have moved to this behavior when hitting <code>ctrl+</code>. </p>
<p>The problem was figuring out an equivalent for FireFox and Opera which don&#8217;t support <code>zoom</code></p>
<h2>Enter CSS 2D Transform</h2>
<p>A little searching and experimenting later I came up with the idea of using <a href="http://www.w3.org/TR/css3-2d-transforms/">CSS Transforms</a> and the <code>scale</code> value to approximate zoom in browsers that lack support. </p>
<p>Let&#8217;s see how I did it. </p>
<p>As you go through the following keep in mind this hasn&#8217;t actually gone through testing yet so something weird could yet shake out. I just wrote this code yesterday, so you guys can be my sanity check.</p>
<p>Also, is anyone else doing this? </p>
<p><span id="more-7817"></span></p>
<p>Here&#8217;s the markup. We had this done weeks ago.</p>
<div class="code-sample"><code>
<pre>
&lt;!-- yes, we get the gas face for href=&quot;#&quot;
I don't like them either.
I'll rewrite it to use just LIs, I swear.
--&gt;
 &lt;ul id=&quot;font-size&quot;&gt;&lt;li class=&quot;text&quot;&gt;Text Size:&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;default&quot;&gt;default font size&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;larger&quot;&gt;larger font size&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#&quot; class=&quot;largest&quot;&gt;largest font size&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;</pre>
<p></code>
</div>
<p>The first thing I did was write a small chunk of code that runs on <code>$(document).ready()</code></p>
<p>(yes, this is a jQuery project.)</p>
<div class="code-sample wide"><code>
<pre>
//using the jQuery cookie plugin to get a pre-set value;
var fontSize=$.cookie('font_size');
//if it exists, set the body.className right now
//and...
//the user gets their size of choice right away
if (fontSize) {
	$(document.body)
    	  .removeClass("largest larger default")
          .addClass(fontSize);
}
$("#font-size li a").click(
	function(e){
		var $body = $(document.body),
		newClass = this.className;
		//if it doesn't already have the chosen class
    	       if (!$body.hasClass(newClass)) {
               //clear any old ones and add the new one
			$body
				.removeClass("largest larger default")
                                .addClass(newClass);
		}
                //saving the choice in a cookie
		$.cookie('font_size',this.className);
                //and finally, stop the clicks
		e.preventDefault();
	}
)
</pre>
<p></code>
</div>
<p>Cool. So far so good. We&#8217;ve got classes on the body indicating how big the user wants to see the site. </p>
<p>Before we look at the CSS, there&#8217;s one more bit of JavaScript we need to look at as I almost immediately envisioned a problem with the above scenario. </p>
<p>If i was using CSS Transforms to scale the pages in Firefox and then Firefox eventually implemented <code>zoom</code>, things would get wonky. We don&#8217;t want that. I had to future-proof the code a little bit. </p>
<p>So, what I needed was a test for the presence of a valid <code>zoom</code> CSS property. Turning to <a href="http://www.modernizr.com/">Modernizr</a> (since it was already in use on the site) I used the handy Modernizr.addTest method to test for zoom. Here&#8217;s the one I cobbled together.</p>
<div class="code-sample"><code>
<pre>
     Modernizr.addTest('zoom', function () {
//create a div
        var test = document.createElement('div');
//if there's a valid property in the browser
//it will return ""
//undefined means the browser doesn't know
//what you're talking about
 	    if (test.style.zoom === undefined) {
		    delete test;
		    return false;
	    }
	    delete test;
        return true;
    });
</pre>
<p></code>
</div>
<p>And finally, we&#8217;ve got the style sheet.  </p>
<div class="code-sample"><code>
<pre>
/*
we add a .default class, so we can reset the page with
the mechanism defined above
*/
body,
body.default {
	font:13px/1.231 arial, helvetica, sans-serif;
	color:#222;
	background:url(images/page-bg.jpg) center repeat-y;
	min-width:960px;
	overflow-x:hidden;
}
/*
here's our class for browsers without a zoom property,
this sets the transform's origin. In this case it defines
the point from which our scale will happen.
We want it to row from the center and from the top,
so 50% and 0 it is.
*/
.no-zoom body {
	-o-transform-origin:50% 0;
	-moz-transform-origin:50% 0;
}
/*
classes for browsers with zoom
*/
.zoom body.larger {
	zoom:110%;
}
.zoom body.largest {
	zoom:125%;
}
/*
and classes for browsers that don't support zoom
*/
.no-zoom body.larger {
    -o-transform: scale(1.1);
    -moz-transform: scale(1.1);
    transform: scale(1.1);
}
.no-zoom body.largest {
    -o-transform: scale(1.25);
    -moz-transform: scale(1.25);
    transform: scale(1.25);
}
</pre>
<p></code>
</div>
<p>And that&#8217;s that. Here&#8217;s a quick demo to see it in action. You can also <a href="/samples/zoom.html.txt">view source here</a>. </p>
<p><iframe src="/samples/zoom.html" width="90%" height="500"></iframe></p>
<h2>Performance</h2>
<p>I did a quick V8 Benchmark comparing scaled/zoomed performance in several browsers to see if there are any issues. The following table shows that there really isn&#8217;t much difference. Clearly this isn&#8217;t a definitive test as it&#8217;s only a small run of tests in one benchmark on one machine, but it was nice that nothing shook out in this first pass. I&#8217;m going to look at doing a DOM heavy test as well as something with some animation (maybe even Canvas?)</p>
<table class="dataTable">
<tr>
<th>Browser</th>
<th>no zoom/scale</th>
<th>zoom:1.5</th>
<th>transform:scale(1.5);</th>
</tr>
<tr>
<td>Chrome 8.0.552.215</td>
<td> 5587 </td>
<td> 5642 </td>
<td>5782</td>
</tr>
<tr>
<td>Firefox 3.6.13</td>
<td> 594</td>
<td>NA</td>
<td>653</td>
</tr>
<tr>
<td>Internet Explorer 8</td>
<td>
<div id="status2">117</div>
</td>
<td>
<div id="status3">120</div>
</td>
<td>NA</td>
</tr>
<tr>
<td>Internet Explorer Platform Preview version 1.9.8023.6000</td>
<td>
<div id="status6">2243</div>
</td>
<td>
<div id="status5">2280</div>
</td>
<td>
<div id="status4">2292</div>
</td>
</tr>
<tr>
<td>Safari 5.03</td>
<td>2839</td>
<td>2874</td>
<td>2796</td>
</tr>
<tr>
<td>Opera 10.63</td>
<td>4071</td>
<td>NA</td>
<td>4110</td>
</tr>
</table>
<p>I kind of like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://htmlcssjavascript.com/css/using-css-zoom-and-css-transforms-for-a-better-increase-text-size-button/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Video From My CSS Presentation at Boston PHP</title>
		<link>http://htmlcssjavascript.com/css/video-from-my-css-presentation-at-boston-php/</link>
		<comments>http://htmlcssjavascript.com/css/video-from-my-css-presentation-at-boston-php/#comments</comments>
		<pubDate>Tue, 23 Nov 2010 14:15:13 +0000</pubDate>
		<dc:creator>Rob Larsen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://htmlcssjavascript.com/?p=7809</guid>
		<description><![CDATA[And here it is: CSS 101 from Matt Murphy on Vimeo. Slides. It&#8217;s pretty good- minus the difficult with actually showing the jsfidddle code on the projector.]]></description>
			<content:encoded><![CDATA[<p>And here it is:</p>
<p><iframe src="http://player.vimeo.com/video/17104934" width="500" height="375" frameborder="0"></iframe>
<p><a href="http://vimeo.com/17104934">CSS 101</a> from <a href="http://vimeo.com/user2835756">Matt Murphy</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><a href="/downloads/css.ppt">Slides.</a></p>
<p>It&#8217;s pretty good- minus the difficult with actually showing the jsfidddle code on the projector. </p>
]]></content:encoded>
			<wfw:commentRss>http://htmlcssjavascript.com/css/video-from-my-css-presentation-at-boston-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More On Interviewing Front End Engineers- If You Ask About Something, Really KNOW It (With an Example Based on the W3C Box Model)</title>
		<link>http://htmlcssjavascript.com/css/more-on-interviewing-front-end-engineers-if-you-ask-about-something-really-know-it-with-an-example-based-on-the-w3c-box-model/</link>
		<comments>http://htmlcssjavascript.com/css/more-on-interviewing-front-end-engineers-if-you-ask-about-something-really-know-it-with-an-example-based-on-the-w3c-box-model/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 15:40:23 +0000</pubDate>
		<dc:creator>Rob Larsen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[interviewing]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[philosophy]]></category>

		<guid isPermaLink="false">http://htmlcssjavascript.com/?p=7793</guid>
		<description><![CDATA[I&#8217;m going to be writing a bit more about practical development topics here over the next few weeks. Code is fun to write about but code takes time. Sharing my experience and opinions on the day-to-day life of a front end engineer I can do with a little less effort. Also, since I&#8217;ve been doing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to be writing a bit more about practical development topics here over the next few weeks. Code is fun to write about but code takes time. Sharing my experience and opinions on the day-to-day life of a front end engineer I can do with a little less effort. Also, since I&#8217;ve been doing it forever and have experience all over the place I feel like I just might have something to share. </p>
<p>Anyway, today I&#8217;m going to continue to talk about the technical interview process. This time with an anecdote culled from my time on the other side of the desk. </p>
<p>I was interviewed a while ago by someone who was significantly junior to me. I think he had maybe 3 years of experience. I was supposed to have been interviewed by someone who would have been a peer at the company, but that fell apart and it fell down to a junior resource. He asked me two questions over a span of ten minutes. Both were worth commenting on, but I&#8217;m going to focus on the first one as it illustrates something pretty important about who you have interviewing people and what they should be expected to be able to figure out about a candidate. </p>
<p>We get on the phone, trade pleasantries and then he gets started. He asks me the following question:</p>
<p>&#8220;You have a div with a width of 300 pixels. It&#8217;s got a margin of 10 pixels. How big is the box?&#8221;<br />
<span id="more-7793"></span><br />
Do you see a problem with that question? </p>
<p>If you&#8217;re trying to test someone on knowledge of the W3C box model, <strong>margin</strong> is meaningless.</p>
<p>The way to ask that question is to use <strong>padding</strong>. Margin sits outside the (visible) box. It&#8217;s part of the element&#8217;s total offset width, but it&#8217;s not part of the visible width. More importantly, <em>that&#8217;s true no matter what box-model you&#8217;re dealing with</em>. So, if you&#8217;re asking about the box, without borders or padding, 300px is going to be 300px no matter what the margin is. </p>
<p>Here&#8217;s a jsfiddle which illustrates that using the CSS3 box-sizing property. Inspect away.</p>
<p><iframe style="width: 100%; height: 600px" src="http://jsfiddle.net/robreact/vtrE6/embedded/"></iframe></p>
<p>So, faced with knowledge of all the above, I asked a follow-up question:</p>
<p>&#8220;Okay, you&#8217;re trying to see if I understand the box model. Cool. So, do you want the size of the div visually (the width of the box) or do you want its offset width? Margin is outside the box so it&#8217;s meaningless for the width of the box.&#8221; </p>
<p>At this point things broke down. I won&#8217;t go into details (especially since .it&#8217;s been over a year,) but the thing I walked away from the conversation with was the plain fact that he wasn&#8217;t prepared for anything other than a number to come back as an answer. I was going to be judged solely on the calculation I did. Things fell apart because his question was poorly worded, focused on the wrong property and he wasn&#8217;t confident enough on the topic to clarify so that I could provide the correct answer. We talked about it for about five minutes and I still don&#8217;t know what the &#8220;right&#8221; answer was.  </p>
<p>As a note, I actually mentioned <code>box-sizing:border-box</code>. I&#8217;m pretty sure that ended up making things worse.</p>
<hr />
<p>When <strong>I</strong> do quizzes like this (and I don&#8217;t- I prefer whiteboard/coding sessions), I&#8217;m <strong>looking</strong> for questions. A lot of times the questions and comments are going to tell me more about a candidate than a quick answer. Questions and comments expose depth. Depth of knowledge = good. </p>
<p>The thing is, to be able to do that I need to absolutely know the subject I&#8217;m asking about. Otherwise&#8230; you get what I experienced, five minutes of frustration and embarrassing gaps in the conversation. </p>
<p>The takeaway? </p>
<p>In a technical interview, only have people cover topics that they really know. If you want junior people to interview, coach the hell out of them on the subjects they&#8217;ll be asking about so that they don&#8217;t end up wasting anyone&#8217;s time.</p>
<hr />
Oh yeah&#8230; You&#8217;re wondering about the other question. It was:</p>
<p>&#8220;What&#8217;s your favorite JavaScript library and why?&#8221;</p>
<p>At which point, I think I fell asleep.</p>
]]></content:encoded>
			<wfw:commentRss>http://htmlcssjavascript.com/css/more-on-interviewing-front-end-engineers-if-you-ask-about-something-really-know-it-with-an-example-based-on-the-w3c-box-model/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thanks to Everyone Who Came out to my CSS Talk</title>
		<link>http://htmlcssjavascript.com/css/thanks-to-everyone-who-came-out-to-my-css-talk/</link>
		<comments>http://htmlcssjavascript.com/css/thanks-to-everyone-who-came-out-to-my-css-talk/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 16:39:23 +0000</pubDate>
		<dc:creator>Rob Larsen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[presentations]]></category>

		<guid isPermaLink="false">http://htmlcssjavascript.com/?p=7748</guid>
		<description><![CDATA[Look at all of the people that showed up for little old me: Sweet. Here are the slides. I&#8217;ll have some video soon (either of this one or of the upcoming version I&#8217;m giving at Design Camp Boston.) Thanks to the folks from Boston PHP for the opportunity and to the guys over Bocoup for [...]]]></description>
			<content:encoded><![CDATA[<p>Look at all of the people that showed up for little old me:</p>
<p><img src="http://htmlcssjavascript.com/wp-content/uploads/2010/10/boston-php.jpg" alt="" title="boston-php" width="600" height="450" class="alignnone size-full wp-image-7749" /></p>
<p>Sweet.</p>
<p>Here are <a href="/downloads/css.ppt">the slides</a>. I&#8217;ll have some video soon (either of this one or of the upcoming version I&#8217;m giving at <a href="http://blog.designcampboston.com/">Design Camp Boston</a>.)</p>
<p>Thanks to the folks from <a href="http://www.meetup.com/bostonphp/">Boston PHP</a> for the opportunity and to the guys over <a href="http://www.bocoup.com/">Bocoup</a> for hosting. </p>
]]></content:encoded>
			<wfw:commentRss>http://htmlcssjavascript.com/css/thanks-to-everyone-who-came-out-to-my-css-talk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How To Make a Web Site the Modern Way. Part 14: Formatting, Shorthand, Resets and Organization</title>
		<link>http://htmlcssjavascript.com/css/how-to-make-a-web-site-the-modern-way-part-14-formatting-shorthand-resets-and-organization/</link>
		<comments>http://htmlcssjavascript.com/css/how-to-make-a-web-site-the-modern-way-part-14-formatting-shorthand-resets-and-organization/#comments</comments>
		<pubDate>Wed, 11 Aug 2010 18:18:43 +0000</pubDate>
		<dc:creator>Rob Larsen</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[how-to-make-a-web-site]]></category>
		<category><![CDATA[methodology]]></category>
		<category><![CDATA[philosophy]]></category>
		<category><![CDATA[standards]]></category>

		<guid isPermaLink="false">http://htmlcssjavascript.com/?p=1018</guid>
		<description><![CDATA[We continue with our examination of CSS with some real basics- formatting, writing rules, organization and the like. Nothing groundbreaking, but the basics are important in any endeavor, so here they are. Formatting During development I format my CSS with selectors on one line and then each property on its own line. The declarations are [...]]]></description>
			<content:encoded><![CDATA[<p>We continue with our examination of CSS with some real basics- formatting, writing rules, organization and the like. Nothing groundbreaking, but the basics are important in any endeavor, so here they are.</p>
<h2>Formatting</h2>
<p>During development I format my CSS with selectors on one line and then each property on its own line. The declarations are indented 4 spaces. I like this style because <strong>my</strong> interest is always in the properties, not the selectors. I can find any selector I need with <code>CTRL+F</code> and then I can easily scan down the list of properties to do my business. </p>
<p>It looks like this:<br />
<span id="more-1018"></span></p>
<div class="code-sample wide"><code>
<pre>
#main article strong {
	font-weight:bold;
}
#text #main article blockquote {
	background:#efefef url(http://d1eucpngoftcha.cloudfront.net/_assets/styles/images/bq-bg.png) no-repeat;
	color:#600;
	font-style: italic;
	margin: 15px auto 30px auto;
	padding: 30px 30px 15px 75px;
}
#text #main article blockquote cite {
	color:#333;
	font-size:90%;
	font-style:normal;
}
#text #main article ul {
	font-size:14px;
	margin: auto auto 30px 15px;
}
</pre>
<p></code></div>
<p>Some people take that approach and indent related or child styles and additional 2 or 4 spaces. That allows for hierarchical scanning and organization and makes (for some people) an easier-to-read style sheet. That looks like this:</p>
<div class="code-sample wide"><code>
<pre>
.post-list li a{
	color:#A8A8A8;
}
    .post-list li a:hover{
        color:#000;
        text-decoration:none;
     }
     .post-list li .author a, .post-list li .author a:hover{
         color:#F30;
       	 text-transform:uppercase;
     }
</pre>
<p></code></div>
<p>Other people like to scan the file for <strong>selectors</strong>, so they produce <a href="http://orderedlist.com/our-writing/blog/articles/single-line-css/">CSS with selectors and declarations on one line</a>. I personally have a hard time with this style, but some people I know swear by it, so I present it here:</p>
<div class="code-sample wide"><code>
<pre>  #wrapper                        {width:800px; margin:0 auto;}
  #header                         {height:100px; position:relative;}
  #feature .post                  {width:490px; float:left;}
  #feature .link                  {width:195px; display:inline; margin:0 10px 0 0; float:right;}
  #footer                         {clear:both; font-size:93%; float:none;}
  #footer .wrapper                {float:none;}
</pre>
<p></code></div>
<p>Whatever style you use, it&#8217;s good practice to minify your CSS before pushing to production so that all the extra characters you pump into your sheets for ease-of-use as a developer don&#8217;t slow down the experience of your users.  </p>
<h2>Shorthand</h2>
<p>There are two ways to approach many families of CSS properties: verbose and shorthand. Verbose properties look like this:</p>
<div class="code-sample wide"><code>
<pre>
.verbose {
    font-family: &quot;Times New Roman&quot;, Times, serif;
    font-size: 12px;
    font-style: italic;
    line-height: normal;
    font-weight: bold;
    color: #003333;
    background-color: #FFFFCC;
    padding-top: 5px;
    padding-right: 10px;
    padding-bottom: 15px;
    padding-left: 20px;
}</pre>
<p></code></div>
<p>Shorthand looks like this:</p>
<div class="code-sample wide"><code>
<pre>
.shorthand {
    color: #003333;
    font: italic bold 12px/normal &quot;Times New Roman&quot;, Times, serif;
    background: #ffffcc;
    padding: 5px 10px 15px 20px;
}</pre>
<p></code></div>
<p>Once you&#8217;re used to it, shorthand is much faster to write and it takes up a lot less space. So&#8230; <strong>use shorthand</strong>. To get you started, here&#8217;s a <a href="http://www.dustindiaz.com/css-shorthand/">fancy guide Dustin Diaz put together a few years ago</a>. It&#8217;s out of date for newer properties, but it&#8217;s useful for the stuff you&#8217;re going to use every day.</p>
<p>One thing that&#8217;s super-useful to remember is the <acronym title="Top Right Bottom Left">TRBL</acronym> acronym which give the order of values in properties like margin and padding.</p>
<h2>Reset Style Sheets</h2>
<p>Much has been written about reset style sheets. I&#8217;m not going to add to the noise here. The point of them, simply, is to level the playing field across browsers so that you start from a common point when creating styles for your site or application. </p>
<p>I use one, and suggest you do too. As to which one, for a while I used a variation of <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">Eric Meyer&#8217;s reset reloaded</a> with the later addition of the following line in place for HTML5 sites to set proper display types for the new elements:</p>
<div class="code-sample wide"><code>
<pre>
article,aside,canvas,figure,footer,header,hgroup,menu,nav,section,summary {
    display:block;
}</pre>
<p></code></div>
<p>For my latest project we&#8217;re using this <a href="http://html5doctor.com/html-5-reset-stylesheet/">HTML5 Reset</a>, which is based on Meyer&#8217;s sheet and adds several HTML5 enhancements. </p>
<p>I like it. </p>
<h2>Organization</h2>
<p>I organize my style sheets by area of the page, seriously influenced by the order in which I work on things. </p>
<p>The basic structure might look something like this:</p>
<pre>
_____________________
|   Copyright                |
------------------------
|   Common colors         |
------------------------
|   Reset Section          |
------------------------
|   Basic Typography     |
------------------------
|   #Header                 |
------------------------
|   #Content                |
------------------------
|   #SideBar                |
------------------------
|   #Footer                 |
------------------------
|   #Random Widgets    |
------------------------
</pre>
<p>I try to comment each section clearly and comment where appropriate outside of the sections to illustrate strange and wondrous constructions.</p>
<p>A small (production) snippet might look like this:</p>
<div class="code-sample"><code>
<pre>
/* -------- COLORS ---------
lightest gray: efefef
light gray: ccc
medium gray: 999
darker gray: 666
darkest gray: 333
light blue links: 69F
body light blue links : 4B87C2
dark blue links : 036
visited: 306
red 930
--------------------------*/
/*reset section*/

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
	margin: 0;
	padding: 0;
	border: 0;
	outline: 0;
	font-weight: inherit;
	font-style: inherit;
	font-size: 100%;
	font-family: inherit;
	vertical-align: baseline;
}
ol, ul {
	list-style: none;
}
caption, th, td {
	text-align: left;
	font-weight: normal;
}
table {
	border-collapse: separate;
	border-spacing: 0;
}
caption, th, td {
	text-align: left;
	font-weight: normal;
}
blockquote:before, blockquote:after, q:before, q:after {
	content: "";
}
blockquote, q {
	quotes: "" "";
}
footer, section, article, nav, header, aside, figure, dialog {
	display:block;
}
body {
	font: 13px Verdana, Arial, Helvetica, sans-serif;
	color: #666;
	background-color:#ccc;
	padding-bottom:50px !important;
}
strong {
	font-weight:bold;
}
em {
	font-style:italic;
}
/*main div- holds the rest of the site*/
#container {
	margin: auto;
	width: 992px;
	background-color:#fff;
}
/*************header*****************/
#header {
	padding-top:20px auto auto 0;
	border-right:10px solid #fff;
	border-left:10px solid #fff;
	position:relative;
}
/*the anchor inside the h1*/
#container #header h1 a {
	text-decoration:none;
	color:#999;
	font: bold 30px Consolas, Inconsolata, &quot;Lucida Console&quot;, Monaco, &quot;Lucida Sans Typewriter&quot;, monospace;
}
#header h1 strong {
	color:#333;
	margin-right:-16px;
}
#header h1 em {
	color:#666;
	margin-right:-16px;
}
#header h1 a:hover {
	text-decoration:underline;
}
/*tagline*/
#respond, #container #header .title {
	font-size: 18px;
	color: #999;
	margin-top:10px auto 20px auto;
	font-style:italic;
}
/*end header*/
/************************main content area*****************/
/*overflow:auto clears floats like magic*/
#content {
	overflow:auto;
	border-right:10px solid #fff;
	border-left:10px solid #fff;
}
/*main copy area*/
#container #copy {
	width:600px;
	border:1px solid #999;
	padding: 16px 10px 16px 12px;
	float:left;
	-moz-border-radius: 12px; /* FF1+ */
	-webkit-border-radius: 12px; /* Saf3+, Chrome */
	border-radius: 12px; /* Opera 10.5, IE 9 */
	-moz-box-shadow: 0px 0px 8px #999; /* FF3.5+ */
	-webkit-box-shadow: 0px 0px 8px #999; /* Saf3.0+, Chrome */
	box-shadow: 0px 0px 8px #999; /* Opera 10.5, IE 9.0 */
	margin-bottom:20px;
}
/******************************/
/* AND SO ON                                   */
/******************************/
</pre>
<p></code></div>
<p>Again, it&#8217;s useful to minify your CSS to strip out all of those comments and all of that whitespace. Comments are good for development though, so be sure to use them. </p>
<hr />
<p>and there you have it. some info on some very basic, but very important CSS practices. Next time we&#8217;ll start to look at common techniques. </p>
<p>Should be fun.  </p>
<hr />
<p><!--showposts tag="how-to-make-a-web-site" num="-1" orderby="date" order="ASC"--></p>
]]></content:encoded>
			<wfw:commentRss>http://htmlcssjavascript.com/css/how-to-make-a-web-site-the-modern-way-part-14-formatting-shorthand-resets-and-organization/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

