<?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</title> <atom:link href="http://divitodesign.com/tag/css/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.2</generator> <item><title>Browser Compatibility Testing for the iPad</title><link>http://divitodesign.com/css/browser-compatibility-testing-for-the-ipad/</link> <comments>http://divitodesign.com/css/browser-compatibility-testing-for-the-ipad/#comments</comments> <pubDate>Thu, 29 Jul 2010 21:07:47 +0000</pubDate> <dc:creator>Stefan Vervoort</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Browser Compatibility]]></category> <category><![CDATA[iPad]]></category><guid isPermaLink="false">http://divitodesign.com/?p=2118</guid> <description><![CDATA[Over time, I have been testing websites for compatibility issues on different browsers and devices. Back in the days, when your website renders flawless in Firefox 2.0, Internet Explorer 6.0 and 7.0, you was there. Today, Browser Compatibility goes much further. We are now not only talking about different browsers and their different versions, but [...]]]></description> <content:encoded><![CDATA[<p>Over time, I have been testing websites for compatibility issues on different browsers and devices. Back in the days, when your website renders flawless in Firefox 2.0, Internet Explorer 6.0 and 7.0, you was there. Today, <strong>Browser Compatibility</strong> goes much further.</p><p>We are now not only talking about different browsers and their different versions, but the <em>screen size</em> of your visitor is as important. With the rise of mobile phones and smartphones, we have another device that can cause troubles for your websites.</p><p>One of those devices is the recently released <strong>Apple iPad</strong>. With <a href="http://ipad.org/tag/ipad-sales-estimates/">over 3 milion iPad&#8217;s sold</a> we have a device to keep in mind. The iPad has the browser Safari installed by default, but there are a few alternatives available. Pretty difficult to keep up with all those browsers, but fortunately the support for HTML/CSS is pretty alright.</p><p>There are a few difficulties along the way as I found out today. Take a look below to read a few tips to make your website iPad compatible.</p><h2>Testing Stage</h2><p>How do you solve compatibility issues for the iPad when you don&#8217;t have one? Fortunately, there are always nice people that develop an app that help: <a href="http://ipadpeek.com/">iPad Peek</a>. All you have to do is enter your URL and you see how your website looks on the iPad. Great tool, check it out.</p><p><a href="http://ipadpeek.com"><img title="Browser Compatibility Testing for the iPad" src="http://divitodesign.com/wp-content/uploads/2010/07/ipad1-435x211.jpg" alt="" width="435" height="211" /></a></p><p><small><em>Browser Compatibility Testing for the iPad</em></small></p><h2>Safari Adds Default Styling to &lt;input&gt; Elements</h2><p>Safari on the iPad adds specific styling the buttons. When you try to add your own style declarations to your button, the default styling overrides that. So how can we change that behavior?</p><p>This solution should work.</p><div class="fvch-code"><pre class="fvch-line-numbers">1
</pre><pre><span class="css">input {    <span class="css-property">-webkit-appearance<span class="css-selector">:</span><span class="css-value"> none</span></span>; }</span></pre></div><h2>Detect iPad for Different Stylesheets</h2><p>To add a stylesheet specifically for smaller devices (as the iPad and iPhone), add this between your <code>head</code> tags:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
</pre><pre><span class="html"><span class="html-other-element">&lt;link media=<span class="html-attribute">&quot;only screen and (max-device-width: 480px)&quot;</span> href=<span class="html-attribute">&quot;small-device.css&quot;</span> type= <span class="html-attribute">&quot;text/css&quot;</span> rel=<span class="html-attribute">&quot;stylesheet&quot;</span>&gt;</span></span></pre></div><p>You can also use this for larger devices:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
</pre><pre><span class="html"><span class="html-other-element">&lt;link media=<span class="html-attribute">&quot;screen and (min-device-width: 481px)&quot;</span> href=<span class="html-attribute">&quot;not-small-device.css&quot;</span> type=<span class="html-attribute">&quot;text/css&quot;</span> rel=<span class="html-attribute">&quot;stylesheet&quot;</span>&gt;</span></span></pre></div><p>This gives you more control over the look of the website for both type of devices. Pretty handy of the iPad isn&#8217;t working with you.</p><p>That&#8217;s it for today, I hope this helps.</p> ]]></content:encoded> <wfw:commentRss>http://divitodesign.com/css/browser-compatibility-testing-for-the-ipad/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Case Study: Revamping an Existing Site</title><link>http://divitodesign.com/css/case-study-revamping-existing-site/</link> <comments>http://divitodesign.com/css/case-study-revamping-existing-site/#comments</comments> <pubDate>Tue, 27 Apr 2010 21:39:00 +0000</pubDate> <dc:creator>Stefan Vervoort</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[case study]]></category> <category><![CDATA[Featured]]></category> <category><![CDATA[guestpost]]></category><guid isPermaLink="false">http://divitodesign.com/?p=2023</guid> <description><![CDATA[Jacques Soudan, a client and friend I met through DivitoDesign, sent me an email with a guest post about a case study on revamping his outdated site. Enjoy reading about his revamping project. Below is a case-study on how I used the Blueprint CSS Framework and jQuery JavaScript library to rebuild an outdated site &#8211; [...]]]></description> <content:encoded><![CDATA[<p><a href="http://troisj.com/">Jacques Soudan</a>, a client and friend I met through DivitoDesign, sent me an email with a guest post about a case study on revamping his outdated site. Enjoy reading about his revamping project.</p><div class="box">Below is a <strong>case-study</strong> on how I used the <a href="http://www.blueprintcss.org/">Blueprint CSS Framework</a> and <a href="http://jquery.com">jQuery JavaScript library</a> to rebuild an outdated site &#8211; somehow you helped me with it, so in return I share my work, hoping it can be of future use. Thank you!</div><p>The website we are talking about was build back in 2001. As you would understand we are talking about a heavily-aged website that had the following &#8216;problems&#8217; or difficulties:</p><ul><li>using some CSS, but mainly tables</li><li>the menu is a separate JS file: easy to maintain, but it doesn&#8217;t look too good</li><li>a few years ago I added the rounded corners (using JavaScript) and the red backdrop/border, but that doesn&#8217;t look too flashy either</li><li>the source is not W3C compliant (outdated code like &lt;br&gt; &#8211; instead of the current &lt;br/&nsbp;&gt;)</li><li>the footer is embedded in each page (hard to update for about 100 pages)</li><li>in general, look &amp; feel is not &#8216;up to date&#8217;</li><li>the enquiry form uses a JavaScript file that is no longer supported</li><li>in Firefox, the banner is not centered (in IE it is&#8230;..) and looks like this (also in a table &#8211; probably easy to fix, but never got to it):</li></ul><p><a href="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot003.jpg"><img class="alignnone size-large wp-image-2024" title="ScreenShot003" src="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot003-434x192.jpg" alt="" width="434" height="192" /></a></p><p>For a website in the modern internet world, that is not acceptable. For this reason, I compiled a list of features I would like to have on the modern, good looking website.</p><h2>Site Features we Need</h2><ul><li>W3C compliant code</li><li>CSS and HTML in separated files</li><li>browser compatibility</li><li>rounded corners &amp; drop shadow</li><li>1 central menu file</li><li>JavaScript support (instead of using several separate scripts that (might) interfere)</li><li>structured design (layout without tables)</li></ul><h2>Where to Start?</h2><p>Last year I read this very useful article about <a href="http://divitodesign.com/css/building-html-css-sites-use-a-template/">building HTML/CSS sites using a template</a>. This template has a grid CSS layout and the jQuery framework build in. I had seen those before, but was not yet using them in combination with <a href="http://wordpress.org">WordPress</a>.</p><p>I also found this site for <a href="http://www.schillmania.com/projects/dialog2/">dropshadow &amp; rounded corners</a>. As I wanted to avoid too many jQuery plugins, I didn&#8217;t use jQuery for the <a href="http://docs.jquery.com/Tutorials:Rounded_Corners">round corners</a>. So far my experience is that jQuery rounded corners can interfere with other plugins, needing too much work to fix (and warrant) it.</p><p>For this reason, the no-Java-script solution seemed preferable. Provided, it had worked &#8211; it did not &#8211; as it uses several &lt;divs&gt;, it messed up the Blueprint classes, it didn&#8217;t display properly &#8216;underneath&#8217; the header images etc. The typical pain when it comes to CSS and different techniques in different browsers.</p><p>So&#8230;. dropping Blueprint? Or dropping the very sleek (and easy!) rounded corners? Dilemma there&#8230;.. Until playing around with Blueprint a bit more&#8230;. as it comes with grid.png, to display the columns for design purposes, which you can switch off when you go live. But then, if you can remove that backdrop, why not adding your own???? Using my own image I had created for the initial technique, but thought useless now, it worked flawlessly!</p><p>Here is what I did &#8211; in the Blueprint folder, there is a screen.css &#8211; just add one line and comment the grid-line &#8211; that&#8217;s all!</p><p><img class="alignnone size-full wp-image-2025" title="ScreenShot004" src="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot004.jpg" alt="" width="456" height="112" /></p><p>In your container-DIV, just add the &#8216;showgrid&#8217;-class: (you need that anyway, if you want to display the Blueprint-columns):</p><p><img class="alignnone size-full wp-image-2026" title="ScreenShot005" src="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot005.jpg" alt="" width="353" height="162" /></p><p>The grid.png is repeated both horizontally &amp; vertically, but my one large image is not, so it fits perfectly &#8211; I stretched it to 1600px, as the backdrop is hardly &#8216;repeatable&#8217;: it is a scanned letterhead-paper with a unique texture &#8211; using only a small slice/strip and repeating that would make it look unnatural. And I use a footer-image &#8211; including it in php, it neatly fits underneath the length of the actual content &#8211; not the full background image of 1600px &#8211; it &#8216;stretches&#8217; to the maximum height, but resizes to the needed height.</p><p>I wanted to use <a href="http://apycom.com/menus/4-red.html">this menu</a> for this website. One problem though: it has no single menu file (eg. menu.php) you can add to your website. After building that menu.php file myself, the jQuery menu worked perfectly.</p><p>When I created the header.php and footer.php files and included in the website using PHP, they are easily updated in those 100 different pages. Depending on the page of the website, I can now include different images via one page. Pretty efficient.</p><h2>The Template</h2><p>With all this now in place, this is how the code looks like (this is what I will use as the &#8216;page-template&#8217; (there is some test copy in, to show in Blueprint columns &#8211; all the &#8216;body-text&#8217; for an individual page is placed within the &lt;content-div&gt; (both &lt;span&gt;-classes, in blue) &#8211; everything remains in place, no fluid/stretched text (in different browsers).</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
</pre><pre><span class="html"><span class="html-comment">&lt;!-- blueprint --&gt;</span>

<span class="html-comment">&lt;!--[if IE]&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;supportfiles/css/ie.css&quot; mce_href=&quot;supportfiles/css/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;&lt;![endif]--&gt;</span>

<span class="html-script-element">&lt;script src=<span class="html-attribute">&quot;supportfiles/js/jquery.js&quot;</span> type=<span class="html-attribute">&quot;text/javascript&quot;</span>&gt;<span class="js"><span class="js"></span></span>&lt;/script&gt;</span>
 <span class="html-script-element">&lt;script src=<span class="html-attribute">&quot;supportfiles/menu/menu.js&quot;</span> type=<span class="html-attribute">&quot;text/javascript&quot;</span>&gt;<span class="js"><span class="js"></span></span>&lt;/script&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;container&quot;</span> class=<span class="html-attribute">&quot;container showgrid&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div id=<span class="html-attribute">&quot;header&quot;</span> class=<span class="html-attribute">&quot;span-24 prepend-top&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;prepend-1 span-22 append-1&quot;</span>&gt;</span><span class="html-other-element">&lt;/div&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 id=<span class="html-attribute">&quot;CONTENT&quot;</span> class=<span class="html-attribute">&quot;prepend-1 span-22 append-1 prepend-top&quot;</span>&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-17&quot;</span>&gt;</span>
<span class="html-other-element">&lt;h1&gt;</span>Main content<span class="html-other-element">&lt;/h1&gt;</span>
Put your main text here (17 columns wide).

<span class="html-other-element">&lt;/div&gt;</span>
<span class="html-other-element">&lt;div class=<span class="html-attribute">&quot;span-5 last&quot;</span>&gt;</span>
<span class="html-other-element">&lt;h3&gt;</span>Sidebar<span class="html-other-element">&lt;/h3&gt;</span>
Some sidebar on the right (5 columns wide).

<span class="html-other-element">&lt;/div&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 id=<span class="html-attribute">&quot;footer&quot;</span> class=<span class="html-attribute">&quot;span-24&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>Blueprint-grid enabled:</p><p><a href="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot010.jpg"><img class="alignnone size-large wp-image-2028" title="ScreenShot010" src="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot010-435x248.jpg" alt="" width="435" height="248" /></a></p><p>And this is how it looks like (pictures not optimized yet):</p><p><a href="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot008.jpg"><img class="alignnone size-large wp-image-2027" title="ScreenShot008" src="http://divitodesign.com/wp-content/uploads/2010/04/ScreenShot008-435x306.jpg" alt="" width="435" height="306" /></a></p><p>I need to finalize the CSS and do some tweaks here and there, but the very flexible yet sturdy framework is there. You can visit <a href="http://www.troisj.com/bm.com/newindex.php">the live version of the website right here</a> to check how it works.</p><p>Thank you &#8211; I hope this is of help to you &#8211; let me know if you have any questions or feedback by adding a comment.</p> ]]></content:encoded> <wfw:commentRss>http://divitodesign.com/css/case-study-revamping-existing-site/feed/</wfw:commentRss> <slash:comments>35</slash:comments> </item> <item><title>CSS Conditional Comments Guide</title><link>http://divitodesign.com/css/css-conditional-comments-guide/</link> <comments>http://divitodesign.com/css/css-conditional-comments-guide/#comments</comments> <pubDate>Mon, 16 Mar 2009 11:55:08 +0000</pubDate> <dc:creator>Stefan Vervoort</dc:creator> <category><![CDATA[CSS]]></category><guid isPermaLink="false">http://www.divitodesign.com/?p=1537</guid> <description><![CDATA[As you might know, Internet Explorer 6 isn&#8217;t the most modern browser out there. In fact, it is almost 8 years old, but many people are still using this un-secure access to the web. Because of this fact, webdesigners still have to worry about how their work looks in Internet Explorer 6. When CSS Frameworks [...]]]></description> <content:encoded><![CDATA[<p>As you might know, Internet Explorer 6 isn&#8217;t the most modern browser out there. In fact, it is almost 8 years old, but many people are still using this un-secure access to the web. Because of this fact, webdesigners still have to worry about how their work looks in Internet Explorer 6.</p><p>When <a href="http://www.divitodesign.com/2009/02/building-html-css-sites-use-a-template/">CSS Frameworks &amp; Templates</a> came around, some layout problems have been fixed, but definitely not all. These problems can usually be solved via normal CSS, but sometimes it is better to only display some (style)information to Internet Explorer users only.</p><p>That is possible with <strong>conditional comments</strong>. Conditional comments are only supported by Internet Explorer versions on a Windows machine. With these &#8216;tricks&#8217;, we can add special behavior to Windows based versions of Internet Explorer 5, 6, 7 and 8. The good thing is that this HTML code <strong>validates</strong> as well.</p><h2>The Form of a Conditional Comment</h2><p>All the conditional comment tags available are based on the same principle. This conditional comment is for all Internet Explorer versions.</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
4
5
</pre><pre><span class="html"><span class="html-comment">&lt;!--[if IE]&gt;
If user browse with an Internet Browser, let's display this.
&lt;![endif]--&gt;</span></span></pre></div><p>Depending on the situation you need to add a version number. Maybe you want to show a different stylesheet to Internet Explorer 5.5:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
</pre><pre><span class="html"><span class="html-comment">&lt;!--[if IE 5.5]&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/ie5.css&quot; mce_href=&quot;css/ie5.css&quot; href=&quot;css/ie5.css&quot; mce_href=&quot;css/ie5.css&quot; href=&quot;css/ie5.css&quot; mce_href=&quot;css/ie5.css&quot; href=&quot;css/ie5.css&quot; mce_href=&quot;css/ie5.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;&lt;![endif]--&gt;</span></span></pre></div><p>Or only to IE7:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
</pre><pre><span class="html"><span class="html-comment">&lt;!--[if IE 7]&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;&lt;![endif]--&gt;</span></span></pre></div><p>You get the point, right?<br /> <span id="more-1537"></span></p><h2>What Else Can We Do?</h2><p>Microsoft have added a couple parameters to these conditional comments too. For example, we can add &#8220;<strong>version Greater Than or Equal to</strong>&#8221; and &#8220;<strong>version Less Than or Equal to</strong>&#8220;. And that&#8217;s pretty handy.</p><p>Let&#8217;s say we want to add a different stylesheet for the Internet Explorer version 7 and below. We can do that like this:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
</pre><pre><span class="html"><span class="html-comment">&lt;!--[if lte IE 7]&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;&lt;![endif]--&gt;</span></span></pre></div><p>Or if we want to create a different stylesheet for version 6 or higher:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
</pre><pre><span class="html"><span class="html-comment">&lt;!--[if gte IE 6]&gt;
	&lt;link rel=&quot;stylesheet&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; href=&quot;css/ie.css&quot; mce_href=&quot;css/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;&lt;![endif]--&gt;</span></span></pre></div><p>We can any of these parameters in our conditional comment:</p><ul><li><strong>lte</strong> &#8211; <em>less than or equal</em></li><li><strong>lt</strong> &#8211; <em>less than</em></li><li><strong>gte</strong> &#8211; <em>greater than or equal</em></li><li><strong>gt</strong> &#8211; <em>great than</em></li><li><strong>(IE6)|(IE7)</strong> &#8211; <em>if Internet Explorer 6 <strong>OR</strong> Internet Explorer 7</em></li><li><strong>(IE6)&amp;(IE7)</strong> &#8211; <em>if Internet Explorer 6 <strong>AND</strong> Internet Explorer 7</em></li><li><a href="http://msdn.microsoft.com/en-us/library/ms537512.aspx">For more examples click here</a></li></ul><h2>Conditional Comments to Ask People to Upgrade Their Out-dated Browser</h2><p>I usually don&#8217;t use conditional comments to fix browser bugs. The way I use them is to tell people they have an out-dated browser. In that message, I tell them they should upgrade their browser for more security and features.</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
4
5
6
</pre><pre><span class="html"><span class="html-comment">&lt;!--[if lt IE 7]&gt;
&lt;p class=&quot;error&quot;&gt;Warning! You are using an out-dated version of Internet Explorer. This version has less features than alternatives and is &lt;b&gt;not secure&lt;/b&gt; to use on the Internet anymore. Please upgrade your browser to &lt;a href=&quot;http://getfirefox.org/&quot; mce_href=&quot;http://getfirefox.org/&quot;&gt;Get Firefox&lt;/a&gt; or &lt;a href=&quot;http://www.microsoft.com/downloads/en/default.aspx&quot; mce_href=&quot;http://www.microsoft.com/downloads/en/default.aspx&quot;&gt;Internet Explorer 7+.&lt;/p&gt;

&lt;![endif]--&gt;</span></span></pre></div><p>Via this way, you can tell people they shouldn&#8217;t be using this version and when they read it, they might upgrade to a more modern browser. As you can see, these conditional tags have many advantages to use in your next website.</p> ]]></content:encoded> <wfw:commentRss>http://divitodesign.com/css/css-conditional-comments-guide/feed/</wfw:commentRss> <slash:comments>5</slash:comments> </item> <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>CSS Resources: The Ultimate Collection</title><link>http://divitodesign.com/css/css-resources-ultimate-collection/</link> <comments>http://divitodesign.com/css/css-resources-ultimate-collection/#comments</comments> <pubDate>Sun, 18 Jan 2009 22:00:25 +0000</pubDate> <dc:creator>Stefan Vervoort</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Featured]]></category> <category><![CDATA[Resources]]></category><guid isPermaLink="false">http://www.divitodesign.com/?p=1376</guid> <description><![CDATA[As a CSS developer (or as a learning CSS developer) you use many resources and sites that help you along the way. May it be as a CSS tool, as a bug fix, or even learning CSS via tutorials. I have compiled the Ultimate List of CSS Resources. If you have a suggestion for an [...]]]></description> <content:encoded><![CDATA[<hr /><img src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-resources.jpg" alt="" /></p><hr />As a CSS developer (or as a learning CSS developer) you use many resources and sites that help you along the way. May it be as a CSS tool, as a bug fix, or even learning CSS via tutorials. I have compiled <strong>the Ultimate List of CSS Resources.</strong></p><p><em>If you have a suggestion for an inclusion, <a href="http://www.divitodesign.com/2009/01/css-resources-ultimate-collection/#respond">please let me know</a> and I will update the list.</em></p><h2>Beginners</h2><p>CSS is a fairly easy language to learn. However, you need to know where to start. Check out the following links to start of well.</p><hr /><img title="css-basics" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-basics.jpg" alt="css-basics" /></p><hr /><ul><li><a href="http://www.w3schools.com/css/css_intro.asp">W3Schools CSS introduction</a></li><li><a href="http://www.yourhtmlsource.com/stylesheets/introduction.html">YourHTMLSource CSS introduction</a></li><li><a href="http://bucarotechelp.com/download/design/basicss.asp">Free CSS Ebook &#8211; Need to subscribe to the RSS feed to download the Ebook!</a></li><li><a href="http://www.cssbasics.com/">CSS Basics</a></li></ul><h2>General</h2><p>Here are some general links that don&#8217;t fit in any of the other sections but are worth mentioning.</p><hr /><img title="css general" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-general.jpg" alt="css general" width="435" height="50" /></p><hr /><ul><li><a href="http://jigsaw.w3.org/css-validator/">CSS validator</a></li><li><a href="http://www.divitodesign.com/2008/07/one-image-equals-multiple-images/">CSS Sprites</a></li><li><a href="http://css-tricks.com/nine-techniques-for-css-image-replacement/">9 Ways to Image Replacement</a></li></ul><h2>CSS Books</h2><p>Although I don&#8217;t read much offline, I&#8217;ve read these CSS books. If you are serious about CSS, you should consider buying any of these books, if not all.</p><hr /><img title="css-books" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-books-435x50.jpg" alt="css-books" /></p><hr /><ul><li><a href="http://www.cssmastery.com/">CSS Mastery</a></li><li><a href="http://www.amazon.com/exec/obidos/ASIN/073571245X">Eric Meyer on CSS &#8211; Mastering the Language Of Webdesign</a></li><li><a href="http://www.amazon.com/CSS-Definitive-Guide-Eric-Meyer/dp/0596527330/"> CSS: The Definitive Guide</a></li><li><a href="http://www.amazon.com/Pro-CSS-HTML-Design-Patterns/dp/1590598040/">Pro CSS and HTML Design Patterns</a></li><li><a href="http://www.simplebits.com/notebook/2007/08/08/bpwd2.html">Bulletproof Web Design</a></li></ul><h2>Write Clean and Organized Code</h2><p>You can write some crappy CSS, or you can create a clean and organized stylesheet. Mastering this will save you time in the end.</p><hr /><img title="clean css" src="http://www.divitodesign.com/wp-content/uploads/2009/01/clean-css.jpg" alt="clean css" /></p><hr /><ul><li><a href="http://woork.blogspot.com/2008/11/useful-guidelines-to-improve-css-coding.html">Useful Guidelines For Clean and Organized Code</a></li><li><a href="http://woork.blogspot.com/2008/03/write-well-structured-css-file-without.html">Write a well structured CSS file without becoming crazy</a></li></ul><p><span id="more-1376"></span></p><h2>CSS Resets</h2><p>Resetting the default CSS interpretation of browsers is a must. Use any of these CSS resets and you can really start building a site from scratch.</p><hr /><img title="css resets" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-resets.jpg" alt="css resets" /></p><hr /><ul><li><a href="http://www.divitodesign.com/2008/03/css-resets-to-improve-website-its-browser-compability/">Basic resets</a></li><li><a href="http://meyerweb.com/eric/tools/css/reset/index.html">Eric Meyer’s reset</a></li><li><a href="http://developer.yahoo.com/yui/reset/">Yahoo!’s Reset</a></li><li><a href="http://rikrikrik.com/log/css-reset">Rik Lomas’ Reset</a></li><li><a href="http://perishablepress.com/press/2007/10/23/a-killer-collection-of-global-css-reset-styles/">Compare the CSS Resets</a></li></ul><h2>CSS Typography</h2><p>Typography is an important part of the web. Use CSS to create beautiful looking headings, paragraphs and more.</p><hr /><img title="css typography" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-typography.jpg" alt="CSS typography" /></p><hr /><ul><li><a href="http://www.divitodesign.com/2008/09/css-typography-tips-and-examples/">CSS &amp; Typography &#8211; Tips and Examples</a></li><li><a href="http://www.divitodesign.com/2008/10/paragraph-typography-guide/">The Paragraph &amp; Typography Guide</a></li><li><a href="http://www.digital-web.com/articles/css_typography/">CSS Typography</a></li><li><a href="http://www.3point7designs.com/blog/2006/09/20/advanced-typography-techniques-using-css/">Advanced Typography Options in CSS</a></li><li><a href="http://jontangerine.com/">CSS &amp; Typography (Jon Tan)</a></li></ul><h2>CSS Compressors</h2><p>Compressing your CSS once you are finished is a great way to optimize your code and make your CSS styles load faster. Make sure you keep a backup of your original stylesheet in case you want to make changes.</p><hr /><img title="css compressors" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-compression.jpg" alt="CSS compressors" /></p><hr /><ul><li><a href="http://iceyboard.no-ip.org/projects/css_compressor">Icey’s CSS Compressor</a></li><li><a href="http://flumpcakes.co.uk/css/optimiser/">FlumpCakes CSS Optimizer</a></li><li><a href="http://floele.flyspray.org/csstidy/css_optimiser.php">CSS Tidy online</a></li><li><a href="http://www.cleancss.com/">Clean CSS</a></li></ul><h2>CSS Cheatsheets</h2><p>CSS cheatsheets can be very handy when you need to reference to a CSS selector. You should print them and put them on your wall!</p><hr /><img title="css-cheatsheets" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-cheatsheets.jpg" alt="css-cheatsheets" /></p><hr /><ul><li><a href="http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/">CSS Cheatsheet by AddedBytes</a></li><li><a href="http://lesliefranke.com/sandbox/ref/csscheatsheet.pdf">Leslie Franke&#8217;s CSS Cheatsheet</a></li><li><a href="http://www.gosquared.com/images/help_sheets/CSS%20Help%20Sheet.pdf">CSS HelpSheet</a></li><li><a href="http://www.veign.com/downloads/guides/qrg0007.pdf">CSS2 Reference Sheet</a></li></ul><h2>CSS Galleries</h2><p>When you are writing CSS, you might need some inspiration along the way. That&#8217;s why CSS galleries are there: the most beautiful CSS layouts right in front of your eyes.</p><hr /><img title="css galleries" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-galleries.jpg" alt="psd-to-html" width="435" height="50" /></p><hr /><ul><li><a href="http://www.cssdrive.com/">CSS Drive</a></li><li><a href="http://www.stylegala.com">StyleGala</a></li><li><a href="http://cssremix.com/">CSS Remix</a></li><li><a href="http://www.designawardsgallery.com/">DesignAwardsGallery</a></li><li><a href="http://www.mostinspired.com/">MostInspired</a></li><li><a href="http://stylizedweb.com/2008/01/18/all-those-web-galleries/">Check out More CSS Galleries</a></li></ul><h2>PSD to HTML</h2><p>It&#8217;s important to be able to import your beautiful layout crafted in Photoshop into a quality HTML and CSS layout. The ins-and-outs can be learned via these tutorials.</p><hr /><img title="psd-to-html" src="http://www.divitodesign.com/wp-content/uploads/2009/01/psd-to-html-435x50.jpg" alt="psd-to-html" /></p><hr /><ul><li><a href="http://nettuts.com/videos/screencasts/converting-a-design-from-psd-to-html/">Converting a Design From PSD to HTML</a></li><li><a href="http://csshowto.com/layout/psd-to-csshtml-in-easy-steps-part-1/">PSD to CSS in 4 lessons</a></li><li><a href="http://www.blog.spoongraphics.co.uk/tutorials/encoding-a-photoshop-mockup-into-xhtml-css">Encoding a Photoshop Mockup to XHTML &amp; CSS</a></li><li><a href="http://css-tricks.com/video-screencasts/1-converting-a-photoshop-mockup-part-1-of-3/">Converting a Photoshop Mockup Screencast</a></li></ul><h2>CSS Frameworks</h2><p>CSS frameworks can be great for coding perfect looking grid layouts with ease. I use them in my projects all the time.</p><hr /><img title="css frameworks" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-frameworks.jpg" alt="css frameworks" /></p><hr /><ul><li><a href="http://960.gs">960 CSS Framework</a></li><li><a href="http://www.blueprintcss.org/">Blueprint CSS Framework</a></li><li><a href="http://developer.yahoo.com/yui/grids/">Yahoo! CSS Framework</a></li><li><a href="http://www.yaml.de/en/home.html">YAML</a></li></ul><h2>CSS Tools</h2><p>There are numberous CSS tools out there that will greatly improve your CSS workflow. I have bookmarked a lot of these tools and it save me lots of time.</p><hr /><img title="css tools" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-tools.jpg" alt="css tools" /></p><hr /><ul><li><a href="http://csstypeset.com/">CSS Type Set</a></li><li><a href="http://riddle.pl/emcalc/">Em Calculator</a></li><li><a href="http://getfirebug.com/">Firebug</a></li><li><a href="http://www.smashingmagazine.com/2008/12/09/50-really-useful-css-tools/">More CSS Tools</a></li></ul><h2>CSS Bugs &amp; How to Solve Them</h2><p>When you are writing CSS, you will find numerous bugs on your path. Keeping a list of websites that will fix them will save you lots of debugging time.</p><hr /><img title="css bugs" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css-bugs.jpg" alt="css bugs" /></p><hr /><ul><li><a href="http://css-tricks.com/ie-css-bugs-thatll-get-you-every-time/">IE CSS Bugs You Will Get Every Time</a></li><li><a href="http://www.positioniseverything.net/">Position Is Everything &#8211; Explains the CSS bugs</a></li><li><a href="http://www.richinstyle.com/bugs/">All Bugs (even IE3!)</a></li><li><a href="http://www.noupe.com/css/using-css-to-fix-anything-20-common-bugs-and-fixes.html">20+ Common CSS Bugs and Fixes</a></li></ul><h2>CSS 3</h2><p>While it can take years until CSS3 is finally supported on all major browsers, you can still use it for browsers that does have the CSS3 support. Just remember, your page should look good without these features too.</p><hr /><img title="css 3" src="http://www.divitodesign.com/wp-content/uploads/2009/01/css3.jpg" alt="css3" /></p><hr /><ul><li><a href="http://www.css3.info/">CSS3.info<br /> </a></li><li><a href="http://www.smashingmagazine.com/2009/01/08/push-your-web-design-into-the-future-with-css3/">Push Your Web Design Into The Future with CSS3</a></li><li><a href="http://css3.com/">CSS3.com</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://divitodesign.com/css/css-resources-ultimate-collection/feed/</wfw:commentRss> <slash:comments>43</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>16</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>63</slash:comments> </item> <item><title>9 Tips to Smaller &amp; Optimized CSS Files</title><link>http://divitodesign.com/css/9-tips-smaller-optimized-css-files/</link> <comments>http://divitodesign.com/css/9-tips-smaller-optimized-css-files/#comments</comments> <pubDate>Sun, 30 Nov 2008 15:55:18 +0000</pubDate> <dc:creator>Stefan Vervoort</dc:creator> <category><![CDATA[CSS]]></category> <category><![CDATA[Featured]]></category><guid isPermaLink="false">http://www.divitodesign.com/?p=1254</guid> <description><![CDATA[Because CSS files are loaded from inside the &#60;head&#62; tags, every visitor download these files. We optimize images and PHP files, but CSS files are often overlooked. We should though and that&#8217;s what we will do today. We can use CSS optimizers to make your CSS file smaller and that works great. However, I feel [...]]]></description> <content:encoded><![CDATA[<p>Because CSS files are loaded from inside the &lt;head&gt; tags, every visitor download these files. We optimize images and PHP files, but CSS files are often overlooked. We should though and that&#8217;s what we will do today.</p><p>We can use <a href="http://www.divitodesign.com/2008/06/css-compressors/">CSS optimizers</a> to make your CSS file smaller and that works great. However, I feel that if you use any of these tips WHILE you are writing CSS codes, your productivity and skill will improve.</p><p>Optimizing your CSS file is also necessary to save bandwidth and to have a good loading time of your page.</p><h2>Tips for optimizing your CSS writing style</h2><h3>1. Comments</h3><p>Comments are especially helpful when writing CSS and your fellow workers need to understand what you are coding. There are different ways of how to add comments though. You can use this:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
4
5
</pre><pre><span class="css"><span class="css-comment">/*-------------------*/</span>
<span class="css-comment">/*-----Comment-------*/</span>
<span class="css-comment">/*-------------------*/</span></span></pre></div><p>While you can use this too:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
</pre><pre><span class="css"><span class="css-comment">/*Comment*/</span></span></pre></div><p>That saves, say 20 characters. Say we have 15 pieces of CSS comments, that saves 300 characters!</p><h3>2. Color Prefixes</h3><p>Color prefixes are defined in HEX codes. The HEX codes are 6 characters long, but in some cases, you can use 3 chars to define the same colors. Take a look at the example:</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">color<span class="css-selector">:</span><span class="css-value"> #ffffff</span></span>; } <span class="css-comment">/* Shortcode: color:#fff; */</span>
div{ <span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #ff88ff</span></span>; } <span class="css-comment">/* Shortcode: color:#f8f; */</span>
div{ <span class="css-property">color<span class="css-selector">:</span><span class="css-value"> #f8f7f2</span></span>; } <span class="css-comment">/* No shortcode possible */</span></span></pre></div><p><span id="more-1254"></span></p><h3>3. Combine Elements</h3><p>For example, if you have a couple elements like <em>h2, h3</em> and<em> h4</em> and all of them have the same properties. They just differ in one point. You can do this:</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
</pre><pre><span class="css">h2, h3, h4{
<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">color<span class="css-selector">:</span><span class="css-value">#333</span></span>;
<span class="css-property">letter-spacing<span class="css-selector">:</span><span class="css-value">.05em</span></span>;
<span class="css-property">word-spacing<span class="css-selector">:</span><span class="css-value">0.1em</span></span>;
}

h2{	<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">1.2em</span></span>; }
h3{	<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">1.1em</span></span>; }
h4{	<span class="css-property">font-size<span class="css-selector">:</span><span class="css-value">1em</span></span>; }</span></pre></div><p>In this way, you have combined the elements and you have added an extra style declaration for the font-size property. This will save you lots of space when you get used to this.</p><h3>4. Leave Out Px/Em/% When Value = Zero</h3><p>The value <em>zero (0)</em> doesn&#8217;t require Px, Em or percentage. 0px is of course the same as 0em or 0%. So when you use the value 0 in your CSS layout (I guess you do!) than this trick will save you a couple chars every time.</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
</pre><pre><span class="css">div{ <span class="css-property">padding<span class="css-selector">:</span><span class="css-value"> 0px 5px 5px 10px</span></span>; }
<span class="css-comment">/* Shortcode: padding: 0 5px 5px 10px; */</span></span></pre></div><h3>5. Combine Properties</h3><p>Some properties as padding, margin and border have been split. For example, padding has padding-top, padding-right, padding-bottom and padding-left.</p><p>If the possibility exist, you should always combine these to one property because it make editing easier and it saves you space too.</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
</pre><pre><span class="css">div{
<span class="css-property">padding-left<span class="css-selector">:</span><span class="css-value">0 </span></span>;
<span class="css-property">padding-top<span class="css-selector">:</span><span class="css-value">50px</span></span>;
<span class="css-property">padding-bottom<span class="css-selector">:</span><span class="css-value">23px</span></span>;
<span class="css-property">padding-right<span class="css-selector">:</span><span class="css-value">4px</span></span>; }

<span class="css-comment">/* Shortcode: padding:50px 4px 23px 0; */</span></span></pre></div><p>When the bottom/top values are the same and the left-right values as well, you can optimize it even more:</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="css">div{
<span class="css-property">padding-top<span class="css-selector">:</span><span class="css-value">5px</span></span>;
<span class="css-property">padding-bottom<span class="css-selector">:</span><span class="css-value">5px</span></span>;
<span class="css-property">padding-left<span class="css-selector">:</span><span class="css-value">0 </span></span>;
<span class="css-property">padding-right<span class="css-selector">:</span><span class="css-value">0px</span></span>; }
<span class="css-comment">/* Shortcode: padding:5px 0; */</span></span></pre></div><h3>6. Choose Classes/ID&#8217;s wisely</h3><p>You should choose classes and ID&#8217;s that are short, easy to understand and descriptive.</p><p>Don&#8217;t choose something like &#8220;<em>HeaderMiddleLeftCategories</em>&#8221; if you can choose something like &#8220;<em>h-cats</em>&#8220;. That save you many chars along the way.</p><h3>7. Save Space by Cleaning up your CSS file</h3><p>When developing CSS websites you have idea&#8217;s that might or might not work. The idea&#8217;s that don&#8217;t work have been coded inside the CSS file, so they take up space and they are not necessary.</p><p>You should look through your CSS file for faults and unnecessary codes. This could save you lots of space.</p><h3>8. Delete Semicolons on the Last Property of a Selector</h3><p>One trick I found out via the use of a <a href="http://www.divitodesign.com/2008/06/css-compressors/">CSS compressor</a> is that you have the possibility to delete the semicolon of the last property of a Selector. Take a look at this example:</p><div class="fvch-code"><pre class="fvch-line-numbers">1
2
3
4
5
6
7
</pre><pre><span class="css">body{
<span class="css-property">background<span class="css-selector">:</span><span class="css-value">#ccc</span></span>;
<span class="css-property">color<span class="css-selector">:</span><span class="css-value">#333</span></span>; }
<span class="css-comment">/* Shortcode: color:#333 */</span></span></pre></div><p>You see I deleted the latest semicolon? This isn&#8217;t a very large optimizing trick, but every char adds up to the sum. Say you have 50 selectors, you save 50 characters.</p><h3>9. Delete Unnecessary Spaces &amp; Enters</h3><p>You might want to delete all the spaces and enters, as they are all count as one character. The problem with deleting these characters is that your CSS file loose structure and is less readable.</p><p>I usually don&#8217;t use this point when optimizing my CSS file because of structure is more important to me. An option to consider is that you save 2 different files, one without enters and spaces (and you use that file on your site), and you keep a copy with the enters and spaces so that editing is still easy to do.</p><h2>Conclusion</h2><p>If you want a CSS file fully optimized, I suggest you use a <a href="http://www.divitodesign.com/2008/06/css-compressors/">CSS compressor</a>. You should teach yourself these tips, so you can write faster and code higher quality CSS.</p><p>Maybe you have other tips you use when optimizing your CSS file and I would love to hear them. <a href="#respond">You should add the tips to the comments!</a></p> ]]></content:encoded> <wfw:commentRss>http://divitodesign.com/css/9-tips-smaller-optimized-css-files/feed/</wfw:commentRss> <slash:comments>34</slash:comments> </item> <item><title>Let Internet Explorer 6 Behave Like Internet Explorer 7</title><link>http://divitodesign.com/css/let-ie6-behave-like-ie7/</link> <comments>http://divitodesign.com/css/let-ie6-behave-like-ie7/#comments</comments> <pubDate>Mon, 17 Nov 2008 18:06:34 +0000</pubDate> <dc:creator>Stefan Vervoort</dc:creator> <category><![CDATA[CSS]]></category><guid isPermaLink="false">http://www.divitodesign.com/?p=1201</guid> <description><![CDATA[We all hate Internet Explorer 6 because the lack of support for CSS and the security issues it has. The browser is 7 year old and dated, but is still used by too many people. Before we are finally ready to make our websites only work in the modern browsers, we have to deal with [...]]]></description> <content:encoded><![CDATA[<p><img class="alignright" title="block ie6" src="http://www.catswhocode.com/blog/wp-content/uploads/2008/06/fuck-ie.png" alt="" width="86" height="86" />We all hate Internet Explorer 6 because the lack of support for CSS and the security issues it has. The browser is 7 year old and dated, but is still used by too many people.</p><p>Before we are finally ready to make our websites only work in the modern browsers, we have to deal with this problem. One solution could be the <strong>IE7.js JavaScript library</strong>.</p><h2>What is the IE7.js JavaScript library?</h2><p>IE7.js is a JavaScript library to make Internet Explorer 6 behave like Internet Explorer 7, a more modern browser. This library fixes many CSS and HTML issues developers are constantly trying to deal with.</p><h2>What bugs does IE7.js fix?</h2><p>Many CSS properties are supported by most modern browsers but not by <abbr title="Internet Explorer 6">IE6</abbr>: IE7.js solve these problems. IE7.js also fixes many <abbr title="Internet Explorer 6">IE6</abbr> bugs that annoyed us from day one. Here are the most important ones:</p><h3>CSS Selectors</h3><ul><li>parent &gt; child</li><li>.multiple.classes</li><li>:hover</li><li>:first-child</li><li>[attr]</li><li>[attr="value"], [attr~="value"], [attr|="value"], [attr^="value"], [attr$="value"]</li><li>[attr*="value"]</li></ul><h3>CSS</h3><ul><li>Background-image &#8211; PNG alpha transparency (IE5.5+)</li><li>Background-attachment &#8211; Support fixed positioning</li><li>Position &#8211; Support fixed positioning</li><li>Margin &#8211; Support auto (IE5.x)</li><li>Cursor &#8211; Support pointer for IE5.x</li><li>Display &#8211; Convert list-item to block for IE5.x</li></ul><h3>HTML</h3><ul><li>img &#8211; PNG alpha transparency</li><li>abbr &#8211; Bug fixed</li></ul><h2>How to implant this library to your website?</h2><p>Yes I am sure you are. Next we will implant the library into your website. You can do that by adding this code between the <em>&lt;head&gt;&lt;/head&gt;</em> tags.</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;!--[if lt IE 7]&gt;

&lt;script src=&quot;http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;![endif]--&gt;</span></span></pre></div><p><span id="more-1201"></span></p><h2>It sounds to good to be true, right?</h2><p>There is only one real disadvantage of this library. Like any other JavaScript script, it won&#8217;t work unless JavaScript is activated on the computer of the user.</p><p>The change exists that <abbr title="Internet Explorer 6">IE6</abbr> users have turned off JavaScript because of the security risks <abbr title="Internet Explorer 6">IE6</abbr> has. And if that&#8217;s the problem, IE7.js won&#8217;t work, and so won&#8217;t the features you have implanted.</p><p>With the result your website might not show correctly on these computers. So, you still have to make sure your website works in IE6 if Javascript is turned down and that doesn&#8217;t solve the whole IE6-hate-thing.</p><h2>Further reading and links</h2><p>If you want more information about this JavaScript library, be sure to visit the following links:</p><ul><li><a href="http://code.google.com/p/ie7-js/">IE7.js&#8217; Google Code page</a></li><li><a href="http://ie7-js.googlecode.com/svn/test/index.html">Test the library</a></li><li><a href="http://meyerweb.com/eric/thoughts/2005/10/17/ie7-and-ie7/">Eric Meyer&#8217;s thoughts</a></li><li><a href="http://dean.edwards.name/">Dean Edwards&#8217; blog (developer)</a></li></ul><h2>The IE8.js file</h2><p>I decided to focus this article on IE7.js because that solves the most common bug fixes a normal developer would require and because Internet Explorer 8 is still in BETA.   If you decide to use the IE8.js file instead of the IE7.js file, here&#8217;s how to do that:<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;!--[if lt IE 8]&gt;

&lt;script src=&quot;http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

&lt;![endif]--&gt;</span></span></pre></div><p><em>Note: You don&#8217;t need to include the IE7.js if you are using IE8.js</em>.</p> ]]></content:encoded> <wfw:commentRss>http://divitodesign.com/css/let-ie6-behave-like-ie7/feed/</wfw:commentRss> <slash:comments>46</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 9/26 queries in 0.070 seconds using disk: basic
Object Caching 1027/1063 objects using disk: basic

Served from: divitodesign.com @ 2012-05-22 10:30:44 -->
