<?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>DivitoDesign &#187; CSS Frameworks</title>
	<atom:link href="http://divitodesign.com/tag/css-frameworks/feed/" rel="self" type="application/rss+xml" />
	<link>http://divitodesign.com</link>
	<description>Articles, Tutorials and Resources for the Webdesigner</description>
	<lastBuildDate>Fri, 07 Oct 2011 18:47:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Building HTML/CSS Sites: Use a Template</title>
		<link>http://divitodesign.com/css/building-html-css-sites-use-a-template/</link>
		<comments>http://divitodesign.com/css/building-html-css-sites-use-a-template/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 13:04:51 +0000</pubDate>
		<dc:creator>Stefan Vervoort</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[CSS Frameworks]]></category>

		<guid isPermaLink="false">http://www.divitodesign.com/?p=1494</guid>
		<description><![CDATA[If you are developing HTML/CSS websites with occasionally a little bit of JavaScript (just like myself), it can be very un-productive to write your basic codes over and over again. For example, if you want to include a JS file for your dropdowns, a CSS framework file and print CSS files every time you start [...]]]></description>
			<content:encoded><![CDATA[<p>If you are developing HTML/CSS websites with occasionally a little bit of JavaScript (just like myself), it can be very un-productive to write your basic codes over and over again.</p>
<p>For example, if you want to include a JS file for your dropdowns, a CSS framework file and print CSS files <strong>every time you start working on a new project</strong>, you better read this article for some time-solving solutions. </p>
<h2>Create a Template for Starting From Scratch</h2>
<p>We are going to make a <strong>Template Folder</strong> we use every time on a new project. This includes a basic index page, the JS files, the CSS files and our basic images. In my projects, I use these files almost every time:</p>
<h3>JavaScript (folder /js/)</h3>
<ul>
<li>pngFix.js (<a href="http://24ways.org/2007/supersleight-transparent-png-in-ie6">to have transparant PNG files in IE6</a>)</li>
<li>custom.js (with a search form fix + the <a href="http://htmldog.com/articles/suckerfish/dropdowns/">suckerfish JS</a> to make dropdowns work)</li>
<li>jQuery.js (to have a good <a href="http://jquery.com/">JS library</a> to start with)</li>
</ul>
<h3>CSS (folder /css/)</h3>
<ul>
<li><a href="http://www.blueprintcss.org/">Blueprint CSS Framework </a>
<ul>
<li>screen.css</li>
<li>print.css</li>
<li>ie.css</li>
</ul>
</li>
<li>custom.css (for all my custom styles)</li>
</ul>
<h3>Images (folder /images/)</h3>
<ul>
<li><a href="http://feedicons.com/">RSS icon</a></li>
</ul>
<p>I suggest you take a look at some of these links I provided in the list and check out what you need yourself in a regular project. If you need other JavaScript fixes or basic CSS code, be sure to use them instead and add them in the same way I will describe below.</p>
<h2 class="tag">Let&#8217;s build our Template&#8217;s Index page</h2>
<p>I hope you have placed all the files you need in an appropriated folder. For example, I have placed my images in /images/, my CSS files in /css/ and my JavaScript files in /js/.  This will make things look pretty structured.</p>
<p>Alright, Let&#8217;s start with a standard HTML page:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre>
<pre><span class="html"><span class="html-other-element">&lt;!DOCTYPE html PUBLIC <span class="html-attribute">&quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span> <span class="html-attribute">&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;</span>&gt;</span>
<span class="html-other-element">&lt;html xmlns=<span class="html-attribute">&quot;http://www.w3.org/1999/xhtml&quot;</span>&gt;</span>
<span class="html-other-element">&lt;head&gt;</span>
<span class="html-other-element">&lt;meta http-equiv=<span class="html-attribute">&quot;Content-Type&quot;</span> content=<span class="html-attribute">&quot;text/html; charset=utf-8&quot;</span> /&gt;</span>
<span class="html-other-element">&lt;title&gt;</span>Untitled Document<span class="html-other-element">&lt;/title&gt;</span>
<span class="html-other-element">&lt;/head&gt;</span>

<span class="html-other-element">&lt;body&gt;</span>
<span class="html-other-element">&lt;/body&gt;</span>
<span class="html-other-element">&lt;/html&gt;</span></span></pre>
</div>
<h3>Description + Keywords + Robots</h3>
<p>Any site needs a <a href="http://www.divitodesign.com/2008/08/seo-keywords-guide/">proper description</a> and maybe some keywords. They won&#8217;t do much to your SEO rankings, but they will help you displaying your search engine results in a proper way. It could also be a good idea to add a meta tag for robots, so your search engine knows they can index your site.<br />
<span id="more-1494"></span><br />
Here is what I have added to my standard META tags. You should add all the following codes + inclusions between the &lt;head&gt;&lt;/head&gt; tags in your HTML page.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="html"><span class="html-other-element">&lt;meta name=<span class="html-attribute">&quot;description&quot;</span> content=<span class="html-attribute">&quot;&quot;</span> /&gt;</span>
    <span class="html-other-element">&lt;meta name=<span class="html-attribute">&quot;keywords&quot;</span> content=<span class="html-attribute">&quot;&quot;</span> /&gt;</span>
    <span class="html-other-element">&lt;meta name=<span class="html-attribute">&quot;robots&quot;</span> content=<span class="html-attribute">&quot;index,follow&quot;</span> /&gt;</span></span></pre>
</div>
<h3>CSS Framework</h3>
<p>We have to add our CSS Framework first. Depending on the way your framework needs inclusion, here is the <a href="http://www.blueprintcss.org/">Blueprint</a> way:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
</pre>
<pre><span class="html"><span class="html-comment">&lt;!-- blueprint --&gt;</span>
    <span class="html-other-element">&lt;link rel=<span class="html-attribute">&quot;stylesheet&quot;</span> href=<span class="html-attribute">&quot;css/screen.css&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span> media=<span class="html-attribute">&quot;screen, projection&quot;</span> /&gt;</span>
    <span class="html-other-element">&lt;link rel=<span class="html-attribute">&quot;stylesheet&quot;</span> href=<span class="html-attribute">&quot;css/print.css&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span> media=<span class="html-attribute">&quot;print&quot;</span> /&gt;</span>
    <span class="html-comment">&lt;!--[if IE]&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;css/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;&lt;![endif]--&gt;</span></span></pre>
</div>
<h3>Custom Styles</h3>
<p>Next, I think it&#8217;s important to have a custom stylesheet at hand, so let&#8217;s add our <em>custom.css</em> stylesheet.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
</pre>
<pre><span class="html"><span class="html-comment">&lt;!-- custom stylesheet --&gt;</span>
    <span class="html-other-element">&lt;link rel=<span class="html-attribute">&quot;stylesheet&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span> media=<span class="html-attribute">&quot;all&quot;</span> href=<span class="html-attribute">&quot;css/custom.css&quot;</span> /&gt;</span></span></pre>
</div>
<h3>JavaScript files</h3>
<p>Now we have added style to our template, let&#8217;s add some JavaScript. I suggest you include <a href="http://www.jquery.com">jQuery</a> first, because if you include jQuery plugins before the original library, they won&#8217;t work. So, here&#8217;s how I include my JavaScript files:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
</pre>
<pre><span class="html"><span class="html-comment">&lt;!-- JavaScript --&gt;</span>
    <span class="html-script-element">&lt;script type=<span class="html-attribute">&quot;text/javascript&quot;</span> src=<span class="html-attribute">&quot;js/jquery.js&quot;</span>&gt;<span class="js"><span class="js"></span></span>&lt;/script&gt;</span>
    <span class="html-script-element">&lt;script type=<span class="html-attribute">&quot;text/javascript&quot;</span> src=<span class="html-attribute">&quot;js/custom.js&quot;</span>&gt;<span class="js"><span class="js"></span></span>&lt;/script&gt;</span>
    <span class="html-comment">&lt;!--[if lte IE 6]&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;js/transparant-png.js&quot;&gt;&lt;/script&gt;&lt;![endif]--&gt;</span></span></pre>
</div>
<p>Everything we needed to include is done right now. We can now start adding some more code to our template&#8217;s Index file.</p>
<h2>Structuring codes</h2>
<p>Depending on your framework, you could add a basic structure between your &lt;body&gt;&lt;/body&gt; tags. Most sites I developed have this structure:</p>
<ul>
<li>Container</p>
<ul>
<li>Header</li>
<li>Content
<ul>
<li>Content</li>
<li>Sidebar 1</li>
<li>Sidebar 2</li>
</ul>
</li>
<li>Footer</li>
</ul>
</li>
</ul>
<p>That&#8217;s why I have already created the structure so I can start right away.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container&quot;</span> id=<span class="html-attribute">&quot;container&quot;</span>&gt;</span>

    <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-24&quot;</span> id=<span class="html-attribute">&quot;header&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&gt;</span><span class="html-comment">&lt;!-- end header --&gt;</span>

    <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-24&quot;</span> id=<span class="html-attribute">&quot;content&quot;</span>&gt;</span>

       <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&gt;</span>
       <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&gt;</span>
<span class="html-comment">&lt;!--	&lt;div class=&quot;&quot;&gt;&lt;/div&gt; --&gt;</span>

    <span class="html-other-element">&lt;/div&gt;</span><span class="html-comment">&lt;!-- end #content --&gt;</span>

    <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-24&quot;</span> id=<span class="html-attribute">&quot;footer&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&gt;</span><span class="html-comment">&lt;!-- end #footer --&gt;</span>

<span class="html-other-element">&lt;/div&gt;</span><span class="html-comment">&lt;!-- end container --&gt;</span></span></pre>
</div>
<p>As you can see, I haven&#8217;t given my DIV&#8217;s inside my Content DIV any ID and I even commented one of them. This is for the simple reason I don&#8217;t know what I will be adding to the content area yet. Every project is different, however, I usually choose two or three DIV&#8217;s inside the content.</p>
<h2 class="tag">Our Custom CSS Files</h2>
<p>Next thing we will do is creating some basic CSS styles. </p>
<p>For example, it is important to structure your codes pretty well. When you need to work fast, you often work less structured and nice. With the use of a template, the structure is already there. You only need to fill it up.</p>
<h3>Comments</h3>
<p>I am not going to teach you how to write structured code as <a href="http://woork.blogspot.com">Woork</a> has some <a href="http://woork.blogspot.com/2008/01/optimize-your-css-files-to-improve-code.html">great</a> <a href="http://woork.blogspot.com/2008/03/write-well-structured-css-file-without.html">tutorials</a> on them. You should always start with the basics details on your project. You can add more or less details in here, that&#8217;s up to you.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre>
<pre><span class="css"><span class="css-comment">/*
Author:           Stefan Vervoort
Author URI:       http://www.divitomedia.com/
Version:	   0.9

Project:
Description:
*/</span></span></pre>
</div>
<p>I think next, a table of contents is appropriated:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre>
<pre><span class="css"><span class="css-comment">/*
---------------------------------------------------------------------------------------
TABLE OF CONTENTS
	-- RESETS
	-- BASICS
	-- CUSTOM
---------------------------------------------------------------------------------------
*/</span></span></pre>
</div>
<p>You should add a heading above each section of your stylesheet. For example, when styling basic stylesheet attributes, you can do it like this:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
</pre>
<pre><span class="css"><span class="css-comment">/*---------------------------------------------------------------------------------------
--- BASICS
---------------------------------------------------------------------------------------*/</span>
body { }
a { }
a:visited{ }
...</span></pre>
</div>
<p>And, next, you add this section to your table of contents. I suggest you only place only your larger sections in your table of contents. This is just a basic lesson in structuring your CSS file.</p>
<h3>CSS Resets</h3>
<p>First, I have added a <strong><a href="http://www.divitodesign.com/2008/03/css-resets-to-improve-website-its-browser-compability/">Reset</a></strong>. My personal favorite is the <a href="http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/">Eric Meijers&#8217; Reset Reloaded</a>. </p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
</pre>
<pre><span class="css"><span class="css-comment">/*---------------------------------------------------------------------------------------
--- RESETS
---------------------------------------------------------------------------------------*/</span>
html, body, div, span, applet, object, iframe,
	p, blockquote, pre,
	a, abbr, acronym, address, big, cite, code,
	del, dfn, em, <span class="css-property">font, img, ins, kbd, q, s, samp,
	small, strike, strong, sub, sup, tt, var,
	b, u, i, center,
	dl, dt, dd, ol, ul, li,
	fieldset, form, label, legend,
	table, caption, tbody, tfoot, thead, tr, th, td {
		margin<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
		<span class="css-property">padding<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
		<span class="css-property">border<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
		<span class="css-property">outline<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
		<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value"> 100%</span></span>;
		<span class="css-property">vertical-align<span class="css-selector">:</span><span class="css-value"> baseline</span></span>;
		<span class="css-property">background<span class="css-selector">:</span><span class="css-value"> transparent</span></span>;
	}
	body {
		<span class="css-property">line-height<span class="css-selector">:</span><span class="css-value"> 1</span></span>;
	}
	ol, ul {
		<span class="css-property">list-style<span class="css-selector">:</span><span class="css-value"> none</span></span>;
	}
	blockquote, q {
		<span class="css-property">quotes<span class="css-selector">:</span><span class="css-value"> none</span></span>;
	}
	blockquote:before, blockquote:after,
	q:before, q:after {
		<span class="css-property">content<span class="css-selector">:</span><span class="css-value"> <span class="css-string">''</span></span></span>;
		<span class="css-property">content<span class="css-selector">:</span><span class="css-value"> none</span></span>;
	}

	:focus {
		<span class="css-property">outline<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
	}

	ins {
		<span class="css-property">text-decoration<span class="css-selector">:</span><span class="css-value"> none</span></span>;
	}
	del {
		<span class="css-property">text-decoration<span class="css-selector">:</span><span class="css-value"> line-through</span></span>;
	}

	table {
		<span class="css-property">border-collapse<span class="css-selector">:</span><span class="css-value"> collapse</span></span>;
		<span class="css-property">border-spacing<span class="css-selector">:</span><span class="css-value"> 0</span></span>;
	}</span></pre>
</div>
<h3>The basics</h3>
<p>The next thing I have added are a couple basic styles, without adding to much behavior. I have added default font sizes, some classes I always use (like .left, .right, .clear, .padding) and some image styles. Be sure to include your own preference in there too.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre>
<pre><span class="css"><span class="css-comment">/*---------------------------------------------------------------------------------------
--- BASICS
---------------------------------------------------------------------------------------*/</span>
html{		<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">100%</span></span>;	<span class="css-property">min-height<span class="css-selector">:</span><span class="css-value">101%</span></span>;}
body{		<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">62.5%</span></span>; <span class="css-property">color<span class="css-selector">:</span><span class="css-value">#666</span></span>;}

a{		}
a:hover{	}
a:active{	}
a:visited{	}

.<span class="css-property">left{		float<span class="css-selector">:</span><span class="css-value">left</span></span>; }
.<span class="css-property">right{	float<span class="css-selector">:</span><span class="css-value">right</span></span>; }
.<span class="css-property">clear{	clear<span class="css-selector">:</span><span class="css-value">both</span></span>; }

img.<span class="css-property">left{	margin<span class="css-selector">:</span><span class="css-value">0 1em 1em 0</span></span>; }
img.<span class="css-property">right{	margin<span class="css-selector">:</span><span class="css-value">0 0 1em 1em</span></span>; }

.<span class="css-property">padding{	padding<span class="css-selector">:</span><span class="css-value">10px</span></span>; }
#<span class="css-property">content p{	margin<span class="css-selector">:</span><span class="css-value">1.1em 0</span></span>; }</span></pre>
</div>
<h3>Dropdown Menu</h3>
<p>Because I tend to use a dropdown menu in all my latest projects, I have all the styles added to my stylesheet to make the dropdown menu work proper, just without color styles. This makes it easy for me to style these menu&#8217;s easily.</p>
<p>If you want to use the <a href="http://htmldog.com/articles/suckerfish/">suckerfish dropdown menu</a> and want to add some basic behavior to your stylesheet, here are my codes. I always place my navigation menu inside a DIV with ID <em>navigation</em>.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre>
<pre><span class="css"><span class="css-comment">/* ------------------------------------------------------------------------------------
NAVIGATION MENU				 */</span>
#navigation, #navigation ul {		<span class="css-property">padding<span class="css-selector">:</span><span class="css-value">0</span></span>;	<span class="css-property">margin<span class="css-selector">:</span><span class="css-value">0</span></span>; <span class="css-property">list-style<span class="css-selector">:</span><span class="css-value">none</span></span>; <span class="css-property">line-height<span class="css-selector">:</span><span class="css-value">1</span></span>; <span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>;	}
#navigation a {			<span class="css-property">display<span class="css-selector">:</span><span class="css-value">block</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">6px 10px</span></span>; <span class="css-property">text-decoration<span class="css-selector">:</span><span class="css-value">none</span></span>;	}
#navigation a:hover{			<span class="css-property">text-decoration<span class="css-selector">:</span><span class="css-value">underline</span></span>; <span class="css-property">padding<span class="css-selector">:</span><span class="css-value">6px 10px</span></span>; }
#navigation li { 			<span class="css-property">float<span class="css-selector">:</span><span class="css-value">left</span></span>; <span class="css-property">width<span class="css-selector">:</span><span class="css-value">auto</span></span>;	}
#navigation li{			<span class="css-property">padding<span class="css-selector">:</span><span class="css-value">0</span></span>; <span class="css-property">margin<span class="css-selector">:</span><span class="css-value">0</span></span>; }
#navigation li ul li{			<span class="css-property">padding<span class="css-selector">:</span><span class="css-value">1px 0px</span></span>;}
#navigation li ul li a{		<span class="css-property">padding<span class="css-selector">:</span><span class="css-value">6px 10px</span></span>; <span class="css-property">width<span class="css-selector">:</span><span class="css-value">110px</span></span>; }
#navigation li ul { 			<span class="css-property">position<span class="css-selector">:</span><span class="css-value">absolute</span></span>; <span class="css-property">padding-top<span class="css-selector">:</span><span class="css-value">1px</span></span>; <span class="css-property">width<span class="css-selector">:</span><span class="css-value">130px</span></span>; <span class="css-property">left<span class="css-selector">:</span><span class="css-value">-999em</span></span>; }
#navigation li ul ul {			<span class="css-property">margin<span class="css-selector">:</span><span class="css-value"> -1.5em 0 0 130px</span></span>;	}

#navigation li:hover ul ul, #navigation li:hover ul ul ul, #navigation li.sfhover ul ul, #navigation li.sfhover ul ul ul {	<span class="css-property">left<span class="css-selector">:</span><span class="css-value"> -999em</span></span>;	}
#navigation li:hover ul, #navigation li li:hover ul, #navigation li li li:hover ul,
#navigation li.sfhover ul, #navigation li li.sfhover ul, #navigation li li li.sfhover ul { <span class="css-property">left<span class="css-selector">:</span><span class="css-value"> auto</span></span>;	}</span></pre>
</div>
<h3>Site Structure</h3>
<p>It&#8217;s easy to gather all your structure DIV&#8217;s and put their ID&#8217;s under each other. This way you always know where to look when something isn&#8217;t right in your structure.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre>
<pre><span class="css"><span class="css-comment">/* ------------------------------------------------------------------------------------
STRUCTURE					 */</span>
#container{	<span class="css-property">overflow<span class="css-selector">:</span><span class="css-value">hidden</span></span>; <span class="css-property">border<span class="css-selector">:</span><span class="css-value">solid #000</span></span>; <span class="css-property">border-width<span class="css-selector">:</span><span class="css-value">0 2px</span></span>; <span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">1.5em</span></span>; }
#header{}
#footer{	<span class="css-property">clear<span class="css-selector">:</span><span class="css-value">both</span></span>; }
#<span class="css-property">content{</span>}
#<span class="css-property">right{</span>}
#<span class="css-property">left{		</span>}</span></pre>
</div>
<h3>Time for the custom code</h3>
<p>My default styles I use in any project are in my stylesheet now. One thing I do next is adding this comment:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
</pre>
<pre><span class="css"><span class="css-comment">/* ------------------------------------------------------------------------------------
CUSTOM				 */</span></span></pre>
</div>
<p>Which means, we are ready to start.</p>
<h2>Template Done</h2>
<p>We are ready to start developing with our new template system. Remember to always make a copy of your template before you start editing there. If you don&#8217;t do that you will loose your basic template, because you&#8217;ll save custom files over your original.</p>
<p>One tip I can give you is to email your template to your own email address. Once you, accidentally, lost your original template, you will be able to retrieve your original one! <a href="http://www.divitodesign.com/2008/05/back-up-your-wordpress-installation/">A backup is a live saver</a>. </p>
<h2>Download my Template</h2>
<p>I can give you my template to use on your own projects and you will have everything all together. I hope you see the advantages of this way of starting on a project and I hope it&#8217;ll save you some time.</p>
<p><a href="http://www.divitodesign.com/wp-content/uploads/css-html-template{divitodesign}.zip">Download HTML-CSS-Template.</a></p>
<h2>Any Tips?</h2>
<p>If you spot any faults in the code, or if you think some code can be optimized, or if you have some tips to add to the template, <a href="http://www.divitodesign.com/2009/02/building-html-css-sites-use-a-template/">don&#8217;t hesitate to leave a comment</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://divitodesign.com/css/building-html-css-sites-use-a-template/feed/</wfw:commentRss>
		<slash:comments>59</slash:comments>
		</item>
		<item>
		<title>Blueprint CSS Framework &#8211; Learn The Basics</title>
		<link>http://divitodesign.com/css/blueprint-css-framework-learn-the-basics/</link>
		<comments>http://divitodesign.com/css/blueprint-css-framework-learn-the-basics/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 18:17:56 +0000</pubDate>
		<dc:creator>Stefan Vervoort</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Frameworks]]></category>

		<guid isPermaLink="false">http://www.divitodesign.com/?p=1419</guid>
		<description><![CDATA[Because of the success of the latest &#8220;Learn the Basics&#8221; article about the 960 CSS Framework, I feel there is a need for detailed tutorials on how to start with CSS Frameworks. It&#8217;s not uncommon that people don&#8217;t know the basics before they start. It&#8217;s time to change that. In the mentioned article, many people [...]]]></description>
			<content:encoded><![CDATA[<p>Because of the success of the latest &#8220;Learn the Basics&#8221; article about the <a href="http://www.divitodesign.com/2008/12/960-css-framework-learn-basics/">960 CSS Framework</a>, I feel there is a need for detailed tutorials on <strong>how to start with CSS Frameworks</strong>. It&#8217;s not uncommon that people don&#8217;t know the basics before they start. It&#8217;s time to change that.</p>
<hr /><img title="Blueprint CSS Framework" src="http://www.divitodesign.com/wp-content/uploads/2009/02/blueprint-1.jpg" alt="blueprint-1" /><br />
<hr />
<p>In the mentioned article, many people commented they like the <a href="http://www.blueprintcss.org/">Blueprint CSS framework</a> more than the <a href="http://960.gs">960.gs</a>. They feel it gives them more flexibility and works easier. That&#8217;s why I took a better look at this CSS framework and decided to teach you exactly how the basics work.</p>
<p><strong>This tutorial will only gives you the basics of the Blueprint CSS framework. You need to understand CSS before you should be using CSS frameworks.</strong></p>
<h2 class="tag">The Basic Principles</h2>
<p>Before you can really develop with this framework you need a few things up-front.</p>
<h2>Which files do you need</h2>
<p>We need to download the CSS framework first. You can download the files <a href="http://www.blueprintcss.org/">here</a>. Once you have opened your .zip/.rar, you will notice a lot of files. That&#8217;s because this isn&#8217;t your basic CSS framework alone, there are many other features we won&#8217;t discuss today.</p>
<p>We only<strong> </strong>need<strong> screen.css</strong>, <strong>print</strong> and <strong>ie.css</strong>, which you can find in the <em>blueprint</em> folder.</p>
<h2>Do not edit templates</h2>
<p>I suggest you don&#8217;t edit these <em>CSS</em> files, because they are part of a template. A template that might gets a few updates in the future and if you add customizations there, you won&#8217;t have an easy updating procedure.</p>
<h2>How to add Blueprint to your site</h2>
<p>Adding Blueprint only requires these lines of codes. You need to insert these between the <em>&lt;head&gt;&lt;/head&gt;</em> tags of your site.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="html"><span class="html-other-element">&lt;link rel=<span class="html-attribute">&quot;stylesheet&quot;</span> href=<span class="html-attribute">&quot;screen.css&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span> media=<span class="html-attribute">&quot;screen, projection&quot;</span>&gt;</span>
<span class="html-other-element">&lt;link rel=<span class="html-attribute">&quot;stylesheet&quot;</span> href=<span class="html-attribute">&quot;print.css&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span> media=<span class="html-attribute">&quot;print&quot;</span>&gt;</span>
<span class="html-comment">&lt;!--[if IE]&gt;&lt;link rel=&quot;stylesheet&quot; href=&quot;ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot;&gt;&lt;![endif]--&gt;</span></span></pre>
</div>
<p><span id="more-1419"></span><br />
But, of course, you want to add some custom styles too. We have to create another separated CSS file that does that. For example, you can call that file <em>style.css.</em> Use this line of codes to add this file to your site.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-other-element">&lt;link rel=<span class="html-attribute">&quot;stylesheet&quot;</span> href=<span class="html-attribute">&quot;style.css&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span>&gt;</span></span></pre>
</div>
<h2 class="tag">What Can Blueprint Do?</h2>
<p>We have a number of classes in the blueprint stylesheets we can use. I will explain the most important ones for our grid layout first.</p>
<h2>Container</h2>
<p>We have to start with a container. By default, this container is 950px width and is centered in the middle of your screen. You can add 24 columns in this container, with a width of 30px per column. A margin of 10px is added to the right side of the column.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<h2>Columns</h2>
<p>There are 24 columns you can choose from. For example, you can choose a layout with 4 boxes with boxes composed of 4, 12, 4 and 4 columns. Here&#8217;s the structure:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-12&quot;</span>&gt;</span>Content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Photos<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Sponsors<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>As you can see, blueprint uses the <em>span-x</em> class to determine how many columns you need to add.</p>
<h2>Margins.</h2>
<p>As you all know, <em>every</em> column in blueprint has a margin-right of 10px. When we leave the structure this way, the last column in the layout will have that margin as well. We don&#8217;t need it there because it&#8217;ll break our layout.</p>
<p>Blueprint has a solution for that in the form of the <em>.last</em> class. Where you add that like this, your layout will render perfectly.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-12&quot;</span>&gt;</span>Content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Photos<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-4 last&quot;</span>&gt;</span>Sponsors<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<h2>Styling Your Columns</h2>
<p>Now that you know how to build your structure with Blueprint, it&#8217;s time to add some padding and maybe a background color. So how are we going to do that when we can&#8217;t touch the original screen.css and print.css? Simple. Remember the style.css file I asked you to make?</p>
<p>First we have to do something about our structure. Due CSS specificity an <strong>ID</strong> is more important than a <strong>Class</strong> and we are going to add ID&#8217;s to all our boxes. When we style ID&#8217;s, we will overrule the styles the classes give.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;sidebar&quot;</span> class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;content&quot;</span> class=<span class="html-attribute">&quot;span-12&quot;</span>&gt;</span>Content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;photos&quot;</span> class=<span class="html-attribute">&quot;span-4&quot;</span>&gt;</span>Photos<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;sponsors&quot;</span> class=<span class="html-attribute">&quot;span-4 last&quot;</span>&gt;</span>Sponsors<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>We can now open up our custom stylesheet (style.css or any other name) and style the ID&#8217;s we have given here. If you don&#8217;t understand what I mean, I suggest you start learning CSS from scratch first.</p>
<p>As an example, I have made a small layout and added some style myself, <a href="/dd-articles/blueprint-basics/index.html">check it out</a>.</p>
<hr /><img title="Blueprint CSS Framework" src="http://www.divitodesign.com/wp-content/uploads/2009/02/blueprint-1.jpg" alt="blueprint-1" /><br />
<hr />
<h2>More Practices</h2>
<p>Blueprint is much more than all the above. For example, you can add classes like .hide (to hide an element), .highlight (to give an element a specific background and highlight the text), add borders, and the default styles for typography and forms are pretty nice as well.</p>
<p>Position classes are added as well, but I haven&#8217;t really worked with that yet. I will post a follow-up article on the Blueprint CSS framework once I have experienced to this CSS framework&#8217;s full potential. You can get a message when this article arrives by <a href="http://feeds2.feedburner.com/DivitoDesign">subscribing to the RSS feed</a> or via <a href="http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1020080&amp;loc=en_US">email</a>.</p>
<h2>More Reading About Blueprint CSS Framework</h2>
<p>There are numerous articles, tutorials and site out there, so if you want to learn more about this framework, check out the links below:</p>
<ul>
<li><a href="http://www.blueprintcss.org/">Blueprint CSS Homepage</a></li>
<li><a href="http://www.blueprintcss.org/tests/">Blueprint&#8217;s demos</a></li>
<li><a href="http://wiki.github.com/joshuaclayton/blueprint-css">Blueprint&#8217;s Wiki</a></li>
<li><a href="http://blueflavor.com/blog/2007/oct/24/blueprint-css-101/">BlueprintCSS 101</a></li>
<li><a href="http://nettuts.com/tutorials/html-css-techniques/a-closer-look-at-the-blueprint-css-framework/">A Closer Look At The Blueprint Framework </a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://divitodesign.com/css/blueprint-css-framework-learn-the-basics/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>Tricks to Solve 960 CSS Framework Problems</title>
		<link>http://divitodesign.com/css/tricks-to-solve-960-css-framework-problems/</link>
		<comments>http://divitodesign.com/css/tricks-to-solve-960-css-framework-problems/#comments</comments>
		<pubDate>Sun, 04 Jan 2009 15:57:26 +0000</pubDate>
		<dc:creator>Stefan Vervoort</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS Frameworks]]></category>

		<guid isPermaLink="false">http://www.divitodesign.com/?p=1317</guid>
		<description><![CDATA[A couple weeks back we have learned about the basics of the 960.gs CSS framework. Today we will talk about 2 problems with the 960 framework you might have struggled with. This post acted like a problem solver. Many of these &#8220;problems&#8221; are very simple to solve. You will need a basic understanding of the [...]]]></description>
			<content:encoded><![CDATA[<p>A couple weeks back we have learned about the <a href="http://www.divitodesign.com/2008/12/960-css-framework-learn-basics/">basics of the 960.gs CSS framework</a>. Today we will talk about 2 problems with the 960 framework you might have struggled with. This post acted like a problem solver.</p>
<p><a href="http://960.gs"><img class="alignnone" title="960 grid system" src="http://960.gs/img/h1.gif" alt="" width="300" height="200" /></a></p>
<p>Many of these &#8220;problems&#8221; are very simple to solve. You will need a basic understanding of the framework though to understand why and how things get solved. <a href="http://www.divitodesign.com/2008/12/960-css-framework-learn-basics/">You should learn the basics here.</a></p>
<h2>Add padding</h2>
<p>All the boxes in the framework have a specific width and margin and this creates the grid look and feel. However, sometimes you want to create a &#8220;box&#8221; or just want to add padding to your div.</p>
<p>As in any framework, this isn&#8217;t possible in the regular way. When you add padding to the div, the div will become wider and this will screw up your whole grid layout.</p>
<h3>Solution</h3>
<p>There is a simple solution to solve this problem. We will add another div <strong>inside</strong> the div you want to add padding to. We <strong>don&#8217;t</strong> give the new div any width declarations. So, we don&#8217;t give it a .<em>grid_xx</em> class.</p>
<p>Now, if we want to style this box and you have added a class or ID, we can add padding. Because we didn&#8217;t specific any width declaration, it is automatically 100%. If we add padding, the width of your div will stay the same. Take a look at our example to clear things up.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_16&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>Let&#8217;s say we want to add padding to the div with ID &#8220;left&#8221;. Usually, like this:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="css">div#<span class="css-property">left{
padding<span class="css-selector">:</span><span class="css-value">10px</span></span>;
}</span></pre>
</div>
<p><span id="more-1317"></span><br />
However, this gives your div an extra 20px width. We work differently today:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_16&quot;</span>&gt;</span>
     <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;left&quot;</span> class=<span class="html-attribute">&quot;grid_8&quot;</span>&gt;</span>
          <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;special-div&quot;</span>&gt;</span>example<span class="html-other-element">&lt;/div&gt;</span>
     <span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>Together with this CSS:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="css">div#<span class="css-property">left div.special-div{
padding<span class="css-selector">:</span><span class="css-value">20px</span></span>;
}</span></pre>
</div>
<p>Take a look at <a href="http://www.divitodesign.com/dd-articles/960-problems-solutions/padding.html">our live example</a> to see this works. As you can see, things are doing fine and the grid isn&#8217;t screwed up! <em>I have added a border/background to the style declaration to make sure you can see what I mean</em></p>
<p><strong>Tip! You can also do this with borders!</strong></p>
<h2>Wider or Narrower 960.gs Layouts</h2>
<p>Width is a specific part of the 960.gs CSS framework. <strong>What if you want to create a layout that is wider or narrower?</strong> The facts first.</p>
<p>The 960.gs framework is called 960 for a reason: it&#8217;s 960px width. The whole grid is based on this 960px. You can&#8217;t make everything narrower or wider because everything gets screwed up. For a narrower layout however, we can use a trick. The wider layout isn&#8217;t possible with 960 gs and you should pick another framework like <a href="http://www.blueprintcss.org">blueprint CSS</a>.</p>
<p>Let&#8217;s create that narrow layout.</p>
<h3>Solution</h3>
<p>There are more CSS codes that can do the job, but I will just use the 960 way today.</p>
<p>Say we have this basic grid:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_16&quot;</span>&gt;</span>
     <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;layout&quot;</span>&gt;</span>layout<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>This means that inside our basic &#8220;container&#8221; div, we have another div. This div with ID &#8220;layout&#8221; will be (<em>surprise!</em>) our layout. You see this div don&#8217;t have a .grid_xx class? Explanation will follow.</p>
<p>We have to put another div behind our &#8220;layout&#8221;-div, so we can position everything. I will give this div the class .grid_12. You can of course change this in an appropriate width. Our grid now looks like this:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_16&quot;</span>&gt;</span>
     <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_12&quot;</span>&gt;</span>
          <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;layout&quot;</span>&gt;</span>layout<span class="html-other-element">&lt;/div&gt;</span>
     <span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>As you can see in the our HTML file, our container&#8217;s width &#8220;is&#8221; 16. Our container div&#8217;s width &#8220;is&#8221; 12.</p>
<p>Simple math shows that 16 &#8211; 12 is 4. We have the width of .grid_4 left. Because we need the same amount of space on both sides of our div, we can do some simple math again. We have .grid_4 / 2 sides = .grid_2 on both sides.</p>
<p>There are classes included in the 960 framework that can add a number of default padding like that <em>.grid_1</em>, <em>.grid_2</em> etc. Padding-left is <em>.prefix_xx</em> and padding-right is <em>.suffix_xx</em>. Let&#8217;s add a padding-left of .grid_2 to our example.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_16&quot;</span>&gt;</span>
     <span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_12 prefix_2&quot;</span>&gt;</span>
          <span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;layout&quot;</span>&gt;</span>layout<span class="html-other-element">&lt;/div&gt;</span>
     <span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>Check out our <a href="http://www.divitodesign.com/dd-articles/960-problems-solutions/width.html">basic example</a> to see that our grid is in the middle of your screen, and narrower as our original 960 layout.</p>
<h2>Conclusion</h2>
<p>These are the problems I was facing when using the 960.gs CSS framework. I don&#8217;t have other problems I think that should be tackled in 960.gs. It works good for me.</p>
<h2>Perhaps you?</h2>
<p>You might have a questions or problem you are facing when using 960 CSS framework in development environments. Don&#8217;t hesitate to point them out in the comments and I will see if I can add a solution in a follow-up post.</p>
]]></content:encoded>
			<wfw:commentRss>http://divitodesign.com/css/tricks-to-solve-960-css-framework-problems/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>960 CSS Framework &#8211; Learn the Basics</title>
		<link>http://divitodesign.com/css/960-css-framework-learn-basics/</link>
		<comments>http://divitodesign.com/css/960-css-framework-learn-basics/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 14:14:41 +0000</pubDate>
		<dc:creator>Stefan Vervoort</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[CSS Frameworks]]></category>

		<guid isPermaLink="false">http://www.divitodesign.com/?p=1292</guid>
		<description><![CDATA[CSS frameworks have been here for some time. About the usefulness of these frameworks has been discussed for numerous times. Some say CSS isn&#8217;t advanced enough, others say these frameworks saved them many hours of developing time. We will not repeat this discussion here. I have discovered CSS frameworks just a while back. After experimenting [...]]]></description>
			<content:encoded><![CDATA[<p>CSS frameworks have been here for some time. About the usefulness of these frameworks has been <a href="http://jeffcroft.com/blog/2007/nov/17/whats-not-love-about-CSS-frameworks/">discussed</a> for numerous times. Some say CSS isn&#8217;t advanced enough, others say these frameworks saved them many hours of developing time. We will not repeat this discussion here.</p>
<p>I have discovered CSS frameworks just a while back. After experimenting with the <a href="http://code.google.com/p/malo/">Malo</a> CSS framework, the <a href="http://www.blueprintcss.org/">Blueprint</a> framework and <a href="http://960.gs/">960</a>, I came to the conclusion <a href="http://960.gs/">I like the 960 CSS framework most</a>.</p>
<p><strong>This tutorial will explain the basics of this framework so you can start developing with 960 pretty fast.</strong></p>
<h2 class="tag">The basics principles</h2>
<p>You have to know a couple basic principles to &#8220;<em>learn how the framework works</em>&#8220;. You can learn these during the experimenting process, but I will explain them here for you, too. Let&#8217;s start.</p>
<h2>Do not edit 960.css</h2>
<p>A small note before: do not edit the 960.css file. If you do this, you won&#8217;t be able to update the framework in the future. Because we need to style our HTML though, we will create a separated CSS file.</p>
<h2>Loading the grid</h2>
<p>Before we can use CSS codes in an external file, we have to load these in our own HTML site. Which can be done via these codes:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
</pre>
<pre><span class="html"><span class="html-special-char">&amp;lt;</span>link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;all&quot; href=&quot;path/to/960/reset.css&quot; /<span class="html-special-char">&amp;gt;</span>
<span class="html-special-char">&amp;lt;</span>link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;all&quot; href=&quot;path/to/960/960.css&quot; /<span class="html-special-char">&amp;gt;</span>
<span class="html-special-char">&amp;lt;</span>link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;all&quot; href=&quot;path/to/960/text.css&quot; /<span class="html-special-char">&amp;gt;</span></span></pre>
</div>
<p>Once we have this ready, we have to include our own CSS file. For example, you can call this file <em>style.css</em> or <em>site.css</em> or anything else. Include this file with these codes:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
</pre>
<pre><span class="html"><span class="html-special-char">&amp;lt;</span>link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;all&quot; href=&quot;path/to/style.css&quot; /<span class="html-special-char">&amp;gt;</span></span></pre>
</div>
<h2>Containers</h2>
<p>In the 960 framework, you can choose between 2 container classes namely <em>.container_12</em> and <em>.container_16</em>. These containers are always 960px width (thence the name 960!) and the difference lies in the number of <strong>Columns</strong>. The <em>.container_12</em> container is divided  into 12 Columns and the <em>.container_16</em> container is divided in 16 columns. These 960px width containers are horizontal centered.</p>
<p><span id="more-1292"></span></p>
<h2>Grids / Columns</h2>
<p>There are numerous column widths you can choose from and these are different in the 2 containers. You can find these widths by opening the <em>960.css</em> file, but this isn&#8217;t necessary to design a proper website. There is a smart trick that make the framework even easier.</p>
<p>For example, if you want 2 columns in your container (say sidebar/content), you can do that this way:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_12&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_4&quot;</span>&gt;</span>sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_8&quot;</span>&gt;</span>main content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>You can see that the sum of your first column (grid_<strong>4</strong>) added with the second column (grid_<strong>8</strong>) is exact <strong>12.</strong> That&#8217;s for a reason, you don&#8217;t have to know the widths of these columns, you can choose column widths doing a very easy bit of math.</p>
<p>Let&#8217;s say we will create a layout with 4 columns. The codes will be these:</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_12&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_2&quot;</span>&gt;</span>sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_6&quot;</span>&gt;</span>main content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_2&quot;</span>&gt;</span>photo's<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_2&quot;</span>&gt;</span>advertisement<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>As you can see, this system works pretty well. If you try to load this in your browser however, you see something that isn&#8217;t right. That&#8217;s the introduction of our next topic.</p>
<h2>Margins</h2>
<p>By default, the columns have some margin between them. Every grid_(insert number here) class has 10px left and right margin. This means that in total, between 2 columns, we have a total margin of 20px.</p>
<p>20px margin is great to create a layout with enough white space to make everything looks smooth. That&#8217;s one reason I enjoyed using 960.</p>
<p>With our example from earlier, we had a problem when we loaded the page in our browser. We are about to fix that.</p>
<p>The problem is that every column has Left <strong>and</strong> Right margin. The first column and the latest column in the container doesn&#8217;t need any margin. Here&#8217;s the solution.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_12&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_2 alpha&quot;</span>&gt;</span>sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_6&quot;</span>&gt;</span>main content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_2&quot;</span>&gt;</span>photo's<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;grid_2 omega&quot;</span>&gt;</span>advertisement<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>You can simple add the class <em>alpha</em> for no left margin, and the class <em>omega</em> for no right margin. This example layout we made is now aligned perfectly in any modern browser (and yes, also in IE6).</p>
<h2>Styling</h2>
<p>Perfect, you know all the basics to create a grid layout with the 960 framework. Of course, we would like to add some style to our layout, too.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre><span class="html"><span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;container_12&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;sidebar&quot;</span> class=<span class="html-attribute">&quot;grid_2 alpha&quot;</span>&gt;</span>sidebar<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;content&quot;</span> class=<span class="html-attribute">&quot;grid_6&quot;</span>&gt;</span>main content<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;photos&quot;</span> class=<span class="html-attribute">&quot;grid_2&quot;</span>&gt;</span>photo's<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;advertisements&quot;</span> class=<span class="html-attribute">&quot;grid_2 omega&quot;</span>&gt;</span>advertisement<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;/div&gt;</span></span></pre>
</div>
<p>Because CSS uses <a href="http://htmldog.com/guides/cssadvanced/specificity/">specificity</a> to determine which style declarations have priority above the other, the <strong>id</strong> is more important then the <strong>classes</strong>.</p>
<p>This way we can overwrite rules that have been set by the classes (like width, padding, borders etc) in our own CSS file.</p>
<p>I have added some style too, which took me exactly 5 minutes to get this whole example together. <a href="http://www.divitodesign.com/dd-articles/960-css-framework-basics/">Check the source for the example and style declarations</a>. <a href="http://www.divitodesign.com/dd-articles/960-css-framework-basics/"><br />
</a></p>
<h2>We are done</h2>
<p>That&#8217;s it. You have just learned how to use the 960.gs framework to build cross browser compatible and smart layouts. When you have completely mastered the 960 framework you will greatly decrease the time you are writing CSS.</p>
<p>If you haven&#8217;t already, check out <a href="http://www.divitodesign.com/dd-articles/960-css-framework-basics/">the example</a>.</p>
<h3>My questions for you!</h3>
<p>Do you use the 960 CSS framework? Or any other framework? Do you think a framework help you to improve your code?</p>
<p><strong>Excellent <a href="http://www.psprint.com/brochures">printing brochures</a> available at <a href="http://psprint.com">PsPrint.com</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://divitodesign.com/css/960-css-framework-learn-basics/feed/</wfw:commentRss>
		<slash:comments>61</slash:comments>
		</item>
	</channel>
</rss>

