<?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>Garrick Cheung &#187; CSS</title>
	<atom:link href="http://www.garrickcheung.com/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.garrickcheung.com</link>
	<description>Sharing what I know and learn about CSS, MooTools, Javascript, PHP and etc.</description>
	<lastBuildDate>Wed, 28 Apr 2010 02:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Search Stylesheet Selectors with MooTools</title>
		<link>http://www.garrickcheung.com/css/search-stylesheet-selectors-with-mootools/</link>
		<comments>http://www.garrickcheung.com/css/search-stylesheet-selectors-with-mootools/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 22:30:52 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=340</guid>
		<description><![CDATA[You should already know that MooTools has Fx.Morph, that allows you to animate multiple css properties on an element and you can also pass it a selector string so you don&#8217;t have to type out all of the properties. Well, you can also pull these properties by using an undocumented method in MooTools, as I [...]]]></description>
			<content:encoded><![CDATA[<p>You should already know that MooTools has Fx.Morph, that allows you to animate multiple css properties on an element and you can also pass it a selector string so you don&#8217;t have to type out all of the properties.</p>
<p>Well, you can also pull these properties by using an undocumented method in MooTools, as I just learned from <a href="http://keetology.com/" target="_blank">Mark Obcena</a>. How? It&#8217;s very simple as you will see.<span id="more-340"></span></p>
<h3>Code</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> selector_rules <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Fx.<span style="color: #660066;">CSS</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.some_class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// returns an object with camelCase key's</span></pre></td></tr></table></div>

<p>See, isn&#8217;t that simple? Keep in mind that this doesn&#8217;t give you every single property. In my tests of running this code with Firebug on <a href="http://www.gamespot.com" target="_blank">GameSpot.com</a>, font-family and overflow properties were missing in the returned object when it clearly shows up in Firebug&#8217;s CSS panel.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/search-stylesheet-selectors-with-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SitePoint&#8217;s Andrew Tetlaw on Styling html and body tags</title>
		<link>http://www.garrickcheung.com/css/andrew-tetlaw-styling-html-and-body/</link>
		<comments>http://www.garrickcheung.com/css/andrew-tetlaw-styling-html-and-body/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 08:59:13 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=296</guid>
		<description><![CDATA[If a page has a background different from it&#8217;s content&#8217;s background, like most people, I usually begin building a page by styling the body tag with one background and a div container where the content would go with another background. SitePoint&#8217;s Andrew Tetlaw wrote up a pretty awesome article on making use of the html [...]]]></description>
			<content:encoded><![CDATA[<p>If a page has a background different from it&#8217;s content&#8217;s background, like most people, I usually begin building a page by styling the body tag with one background and a div container where the content would go with another background. <a href="http://www.sitepoint.com/blogs/2009/02/11/styling-the-html-and-body-elements/" target="_blank">SitePoint&#8217;s Andrew Tetlaw wrote up a pretty awesome article</a> on making use of the html tag along with the body tag so I won&#8217;t have to add redundant tags for backgrounds.<span id="more-296"></span></p>
<h3>The Take Away</h3>
<p>If you didn&#8217;t head over to Andrew&#8217;s article to learn the ins-and-outs of his explanation, which I think you should because you&#8217;ll understand why you&#8217;re using this code, here are the two main things I learned:</p>
<blockquote><p>Adding a background image to the html and body elements works fine, and you can use it in place of multiple background images that only Safari currently supports.</p></blockquote>
<p>And&#8230;</p>
<blockquote><p>There’s one big gotcha though: if you need to use absolute or relative positioning for elements inside the body element. I’d assumed that since all elements obtain a positioning context from the body element by default, if I centered the body element the default positioning context should adjust accordingly. I was wrong! The default positioning context remains fixed to the viewport; you have to add position:relative; to the body style to create a new positioning context.</p></blockquote>
<h3>The Code</h3>
<p>So, you end up with this awesome code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">html <span style="color: #00AA00;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
body <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">750px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Thank you Andrew! I&#8217;ve learned a lot from your article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/andrew-tetlaw-styling-html-and-body/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>CSS Best Practice #4: Understand Selector Specificity for Better Speed and Easier Override</title>
		<link>http://www.garrickcheung.com/css/css-best-practice-4-understand-selector-specificity-for-speed-and-override/</link>
		<comments>http://www.garrickcheung.com/css/css-best-practice-4-understand-selector-specificity-for-speed-and-override/#comments</comments>
		<pubDate>Sat, 10 Jan 2009 23:22:11 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=261</guid>
		<description><![CDATA[Understanding the specificity of CSS selectors is important because it makes overriding your previous styles easier. The fastest to slowest selectors also corresponds to how easy it will be to override the cascaded and/or inherited style rules. Selectors: Fast to Slow Jon Sykes did some CSS performance testing and the results show which selectors were [...]]]></description>
			<content:encoded><![CDATA[<p>Understanding the specificity of CSS selectors is important because it makes overriding your previous styles easier. The fastest to slowest selectors also corresponds to how easy it will be to override the cascaded and/or inherited style rules.<span id="more-261"></span></p>
<h3>Selectors: Fast to Slow</h3>
<p><a href="http://jon.sykes.me/153/more-css-performance-testing-pt-3" target="_blank">Jon Sykes did some CSS performance testing</a> and the results show which selectors were fast/slow. You can check out his post for his approach, which includes a zip file of the html files he used. Just so you know, there&#8217;s probably more testing to be done, such as testing pseudo-classes and different combination&#8217;s of selectors. I&#8217;ll just give you the summary of his results, from fastest to slowest.</p>
<ol>
<li>Tag &#8211; a</li>
<li>Class &#8211; .class</li>
<li>Descender &#8211; div div div p a.class</li>
<li>Child &#8211; div > div > div > p > a.class</li>
</ol>
<h3>Selectors: Specificity</h3>
<p>Remember the saying: &#8220;Less is more&#8221; because that is the case here. <a href="http://reference.sitepoint.com/css/specificity" target="_blank">Sitepoint&#8217;s CSS Reference&#8217;s</a> definition:</p>
<blockquote><p><strong>Specificity</strong> is a mechanism within the CSS cascade that aids conflict resolution. The concept of specificity states that when two or more declarations that apply to the same element, and set the same property, have the same importance and origin, the declaration with the most specific selector will take precedence.</p></blockquote>
<p>So when we compare specificity to Jon&#8217;s results, the more specific the selector, the slower it is. I also find that the more specific selectors takes up more time and keystrokes.</p>
<p>For example, I have this HTML to style:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;latest_news&quot;&gt;
    &lt;div class=&quot;box&gt;
        &lt;ul class=&quot;stories_list&quot;&gt;
            &lt;li&gt;
                &lt;div class=&quot;info&quot;&gt;
                    &lt;a class=&quot;headline&quot;&gt;Around the Globe&lt;/a&gt;
                &lt;/div&gt;
            &lt;/li&gt;
            &lt;li&gt;
                &lt;div class=&quot;info&quot;&gt;
                    &lt;a class=&quot;headline&quot;&gt;Current Events&lt;/a&gt;
                &lt;/div&gt;
            &lt;/li&gt;
        &lt;/ul&gt;
    &lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p><strong>Example Styles 1.</strong><br />
Say I want to style the headlines in that story list. The general style is short, thus it SHOULD be fast. The override is a little longer so it&#8217;s a little slower.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* General style to start */</span>
<span style="color: #6666ff;">.story_list</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Override style */</span>
<span style="color: #6666ff;">.latest_news</span> <span style="color: #6666ff;">.story_list</span> a<span style="color: #6666ff;">.headline</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><strong>Example Styles 2.</strong><br />
The following styles the same HTML above, but they are much longer.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* General style to start */</span>
div <span style="color: #6666ff;">.box</span> <span style="color: #6666ff;">.story_list</span> li <span style="color: #6666ff;">.info</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">14px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">font-weight</span><span style="color: #00AA00;">:</span><span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* Override style */</span>
div<span style="color: #6666ff;">.latest_news</span> <span style="color: #6666ff;">.box</span> <span style="color: #6666ff;">.story_list</span> li <span style="color: #6666ff;">.info</span> a<span style="color: #6666ff;">.headline</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">12px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>When you compare styles #1 and styles #2, you&#8217;ll notice that #1 is easier to override because it&#8217;s short. #2 takes a few more class names before it can override the general styles.</p>
<h3>Conclusion</h3>
<p>So what I&#8217;m saying is to keep things short and sweet. It will be easier to override when your stylesheet becomes complex. It will be faster too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/css-best-practice-4-understand-selector-specificity-for-speed-and-override/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>IE7 CSS Pseudo Selector Slowdown?</title>
		<link>http://www.garrickcheung.com/css/ie7-css-pseudo-selector-slowdown/</link>
		<comments>http://www.garrickcheung.com/css/ie7-css-pseudo-selector-slowdown/#comments</comments>
		<pubDate>Sat, 27 Dec 2008 07:46:11 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[pseudo]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=248</guid>
		<description><![CDATA[Have you ever experienced major slowdown using IE7? It may NOT be memory related. I came across this issue while working on a bug for GameSpot. Users were complaining that the user experience was lagging. It&#8217;s more noticeable with the forums, where the users would drag the scroll bar in long threads, but the page [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever experienced major slowdown using IE7? It may NOT be memory related. I came across this issue while working on a bug for <a href="http://www.gamespot.com" target="_blank">GameSpot</a>. Users were complaining that the user experience was lagging. It&#8217;s more noticeable with the forums, where the users would drag the scroll bar in long threads, but the page wouldn&#8217;t scroll for a few seconds. <a href="http://www.gamespot.com/users/rockmfr/" target="_blank">RockMFR</a> had the solution, which I shall share with you.<span id="more-248"></span></p>
<h3>The Solution</h3>
<p>It was related to a pseudo selector in CSS, :hover to be exact. I&#8217;ll simplify it so it won&#8217;t look exactly like what it did on <a href="http://www.gamespot.com" target="_blank">GameSpot</a>. The line was incorrectly coded.</p>
<p><strong>Problem</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#some_container</span> <span style="color: #6666ff;">.anchor</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><strong>Solution</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#some_container</span> a<span style="color: #6666ff;">.anchor</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Do you see the difference there? The incorrect way was missing the &#8220;a&#8221;. I&#8217;m not totally positive why this would cause IE7 to hiccup but my theory is that IE7 was trying to apply :hover onto the element with the &#8220;anchor&#8221; class, but had trouble finding it. And because the thread was so long, IE7 MAY have been trying to render and apply the rule to the element with the &#8220;anchor&#8221; class. Another thing is that the rule wasn&#8217;t even being applied in the forum pages, which makes things odd.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/ie7-css-pseudo-selector-slowdown/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS Best Practice #3: Clear Floated Containers (with Height&#124;&#124;Width and Overflow)</title>
		<link>http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/</link>
		<comments>http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 01:00:21 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[HTML / XHTML]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[clear float]]></category>
		<category><![CDATA[hasLayout]]></category>
		<category><![CDATA[overflow]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=217</guid>
		<description><![CDATA[I know you&#8217;ve done it before. I think we&#8217;ve all done it. You have a container with a floated element inside. The container doesn&#8217;t wrap around everything, thus causing the element to break outside of the container. To fix this, we&#8217;d usually add a clear element at the bottom of the container so it would [...]]]></description>
			<content:encoded><![CDATA[<p>I know you&#8217;ve done it before. I think we&#8217;ve all done it. You have a container with a floated element inside. The container doesn&#8217;t wrap around everything, thus causing the element to break outside of the container. To fix this, we&#8217;d usually add a clear element at the bottom of the container so it would wrap everything within. But there is a better solution, which uses two CSS properties. For this example, I&#8217;ll place the styles inline.. please don&#8217;t hate me.<span id="more-217"></span></p>
<p><strong>If you want to just get to the <a href="#solution">better solution&#8230;</a></strong></p>
<h3>The Example</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot; style=&quot;border:1px solid #000;&quot;&gt;
    &lt;img src=&quot;something.gif&quot; height=&quot;50&quot; width=&quot;50&quot; alt=&quot;Alt img txt&quot; style=&quot;background:green; float:left;&quot; /&gt;
    &lt;p style=&quot;margin:0;&quot;&gt;Text inside the container div.&lt;/p&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>Proceeding with the example, div.clear is placed at the bottom of div.container, which solves the problem. Div.container&#8217;s border now wraps all the elements within.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot; style=&quot;border:1px solid #000;&quot;&gt;
    &lt;img src=&quot;something.gif&quot; height=&quot;50&quot; width=&quot;50&quot; alt=&quot;Alt img txt&quot; style=&quot;background:green; float:left;&quot; /&gt;
    &lt;p style=&quot;margin:0;&quot;&gt;Text inside the container div.&lt;/p&gt;
    &lt;div class=&quot;clear&quot; style=&quot;clear:both;&quot;&gt;&lt;/div&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<h3><a name="solution"></a>The Better Solution</h3>
<p>But why should we even bother placing an extra element? It&#8217;s not sexy. Here&#8217;s the solution: Use height:1% or width:100% and overflow:auto||hidden on div.container. Height and width on div.container would set the hasLayout property in IE, thus fixing a slew of float/box-model bugs (<a href="http://www.satzansatz.de/cssd/onhavinglayout.html" target="_blank">more on hasLayout</a>). Overflow auto or hidden tells div.container to wrap everything within it.</p>
<p><strong>Note:</strong> This won&#8217;t work if the element is floated, which would cause it to shrink to the percentage height or width.</p>
<p>The HTML</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot; style=&quot;border:1px solid #000;&quot;&gt;
    &lt;img src=&quot;something.gif&quot; height=&quot;50&quot; width=&quot;50&quot; alt=&quot;Alt img txt&quot; style=&quot;background:green; float:left;&quot; /&gt;
    &lt;p style=&quot;margin:0;&quot;&gt;Text inside the container div.&lt;/p&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>The CSS</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">1</span>%</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CSS Best Practice #2: Shorthand Properties</title>
		<link>http://www.garrickcheung.com/css/css-best-practice-2-shorthand-properties/</link>
		<comments>http://www.garrickcheung.com/css/css-best-practice-2-shorthand-properties/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 19:00:30 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[short hand]]></category>
		<category><![CDATA[shorthand]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=210</guid>
		<description><![CDATA[Write your CSS rules with shorthand properties. It keeps things simple and clean. 1 2 3 4 5 6 7 8 9 10 .example &#123; /* long */ padding-top:1px; padding-right:2px; padding-bottom:3px; padding-left:4px; &#160; /* short */ padding:1px 2px 3px 4px; &#125; To help you with the shorthand, Dustin Diaz took the time to put together [...]]]></description>
			<content:encoded><![CDATA[<p>Write your CSS rules with shorthand properties. It keeps things simple and clean.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.example</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #808080; font-style: italic;">/* long */</span>
    <span style="color: #000000; font-weight: bold;">padding-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">3px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding-left</span><span style="color: #00AA00;">:</span><span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* short */</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">1px</span> <span style="color: #933;">2px</span> <span style="color: #933;">3px</span> <span style="color: #933;">4px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>To help you with the shorthand, Dustin Diaz took the time to put together a <a href="http://www.dustindiaz.com/css-shorthand/" target="_blank">CSS shorthand guide</a>. Way to go Dustin! Check the guide for in-depth descriptions, examples, and Dustins &#8220;quirky facts&#8221; (such as shorthand defaults).</p>
<p><a href="http://reference.sitepoint.com/css" target="_blank">SitePoint CSS Reference</a> is another source for shorthand properties, or any property in general, you should/could/would use.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/css-best-practice-2-shorthand-properties/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>CSS Best Practice #1: Reset CSS</title>
		<link>http://www.garrickcheung.com/css/css-best-practice-1-reset-css/</link>
		<comments>http://www.garrickcheung.com/css/css-best-practice-1-reset-css/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 13:01:25 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[reset css]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=193</guid>
		<description><![CDATA[I think resetting browser styles is important. You&#8217;ll never know what you&#8217;re dealing with. If all the browsers start on the same page it will make your life easier because you&#8217;ll know what to expect. I personally use Eric Meyer&#8217;s Reset CSS as a base and modify it as needed. 1 2 3 4 5 [...]]]></description>
			<content:encoded><![CDATA[<p>I think resetting browser styles is important. You&#8217;ll never know what you&#8217;re dealing with. If all the browsers start on the same page it will make your life easier because you&#8217;ll know what to expect. I personally use <a href="http://meyerweb.com/eric/tools/css/reset/" target="_blank">Eric Meyer&#8217;s Reset CSS</a> as a base and modify it as needed.<span id="more-193"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>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
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* v1.0 | 20080212 */</span>
&nbsp;
html<span style="color: #00AA00;">,</span> body<span style="color: #00AA00;">,</span> div<span style="color: #00AA00;">,</span> span<span style="color: #00AA00;">,</span> applet<span style="color: #00AA00;">,</span> object<span style="color: #00AA00;">,</span> iframe<span style="color: #00AA00;">,</span>
h1<span style="color: #00AA00;">,</span> h2<span style="color: #00AA00;">,</span> h3<span style="color: #00AA00;">,</span> h4<span style="color: #00AA00;">,</span> h5<span style="color: #00AA00;">,</span> h6<span style="color: #00AA00;">,</span> p<span style="color: #00AA00;">,</span> blockquote<span style="color: #00AA00;">,</span> pre<span style="color: #00AA00;">,</span>
a<span style="color: #00AA00;">,</span> abbr<span style="color: #00AA00;">,</span> acronym<span style="color: #00AA00;">,</span> address<span style="color: #00AA00;">,</span> big<span style="color: #00AA00;">,</span> cite<span style="color: #00AA00;">,</span> code<span style="color: #00AA00;">,</span>
del<span style="color: #00AA00;">,</span> dfn<span style="color: #00AA00;">,</span> em<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">,</span> img<span style="color: #00AA00;">,</span> ins<span style="color: #00AA00;">,</span> kbd<span style="color: #00AA00;">,</span> q<span style="color: #00AA00;">,</span> s<span style="color: #00AA00;">,</span> samp<span style="color: #00AA00;">,</span>
small<span style="color: #00AA00;">,</span> strike<span style="color: #00AA00;">,</span> strong<span style="color: #00AA00;">,</span> sub<span style="color: #00AA00;">,</span> sup<span style="color: #00AA00;">,</span> tt<span style="color: #00AA00;">,</span> var<span style="color: #00AA00;">,</span>
b<span style="color: #00AA00;">,</span> u<span style="color: #00AA00;">,</span> i<span style="color: #00AA00;">,</span> <span style="color: #993333;">center</span><span style="color: #00AA00;">,</span>
dl<span style="color: #00AA00;">,</span> dt<span style="color: #00AA00;">,</span> dd<span style="color: #00AA00;">,</span> ol<span style="color: #00AA00;">,</span> ul<span style="color: #00AA00;">,</span> li<span style="color: #00AA00;">,</span>
fieldset<span style="color: #00AA00;">,</span> form<span style="color: #00AA00;">,</span> label<span style="color: #00AA00;">,</span> legend<span style="color: #00AA00;">,</span>
table<span style="color: #00AA00;">,</span> caption<span style="color: #00AA00;">,</span> tbody<span style="color: #00AA00;">,</span> tfoot<span style="color: #00AA00;">,</span> thead<span style="color: #00AA00;">,</span> tr<span style="color: #00AA00;">,</span> th<span style="color: #00AA00;">,</span> td <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">baseline</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">transparent</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
body <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
ol<span style="color: #00AA00;">,</span> ul <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #00AA00;">,</span> q <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">quotes</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
blockquote<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> blockquote<span style="color: #3333ff;">:after</span><span style="color: #00AA00;">,</span>
q<span style="color: #3333ff;">:before</span><span style="color: #00AA00;">,</span> q<span style="color: #3333ff;">:after </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">''</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">content</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* remember to define focus styles! */</span>
<span style="color: #3333ff;">:focus </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">outline</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* remember to highlight inserts somehow! */</span>
ins <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
del <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">line-through</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* tables still need 'cellspacing=&quot;0&quot;' in the markup */</span>
table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">border-collapse</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">collapse</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">border-spacing</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<h3>Other Resets</h3>
<p>There are actually a lot more choices besides Eric Meyers. I found several more at a <a href="http://www.pinceladasdaweb.com.br/blog/2008/11/10/10-tecnicas-para-reset-css/" target="_blank">post on Pinceladas da Web</a>. It is in Portuguese so you may need to translate.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/css-best-practice-1-reset-css/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>CSS Best Practices: Index</title>
		<link>http://www.garrickcheung.com/css/css-best-practices-index/</link>
		<comments>http://www.garrickcheung.com/css/css-best-practices-index/#comments</comments>
		<pubDate>Sun, 30 Nov 2008 13:00:52 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[best practice]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=160</guid>
		<description><![CDATA[I&#8217;ve decided to create an index of all the CSS best practices in this post that will be updated when I add a new best practice. It should be easier for you to keep track of everything. Please bear with me while I get things together. CSS Best Practices Posts: Reset CSS CSS Best Practice [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to create an index of all the CSS best practices in this post that will be updated when I add a new best practice. It should be easier for you to keep track of everything. Please bear with me while I get things together.<span id="more-160"></span></p>
<h3>CSS Best Practices Posts:</h3>
<ol>
<li><a href="http://www.garrickcheung.com/css/css-best-practice-1-reset-css/">Reset CSS</a></li>
<li><a href="http://www.garrickcheung.com/css/css-best-practice-2-shorthand-properties/">CSS Best Practice #2: Shorthand Properties</a></li>
<li><a href="http://www.garrickcheung.com/css/css-best-practice-3-clear-floated-containers-with-heightwidth-and-overflow/"><br />
CSS Best Practice #3: Clear Floated Containers (with Height||Width and Overflow)</a></li>
<li><a href="http://www.garrickcheung.com/css/css-best-practice-4-understand-selector-specificity-for-better-speed-and-easier-override/">CSS Best Practice #4: Understand Selector Specificity for Better Speed and Easier Override</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/css-best-practices-index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Limitations of CSS Files in IE</title>
		<link>http://www.garrickcheung.com/css/limitations-of-css-files-in-ie/</link>
		<comments>http://www.garrickcheung.com/css/limitations-of-css-files-in-ie/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 19:30:38 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[limit]]></category>
		<category><![CDATA[limitation]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=189</guid>
		<description><![CDATA[If you didn&#8217;t know already, IE puts a limit on stylesheet file sizes to cap off at 288Kb. Another limitation I learned from Martin Ivanov&#8217;s post is that IE limits the number of stylesheets loaded via link tag or @import to 32 files. Make use of compression and minification if you&#8217;ve got large files and [...]]]></description>
			<content:encoded><![CDATA[<p>If you didn&#8217;t know already, IE puts a limit on stylesheet file sizes to cap off at 288Kb. Another limitation I learned from <a href="http://acidmartin.wordpress.com/2008/11/25/the-32-external-css-files-limitation-of-internet-explorer-and-more/" target="_blank">Martin Ivanov&#8217;s post</a> is that IE limits the number of stylesheets loaded via link tag or @import to 32 files.</p>
<p>Make use of compression and minification if you&#8217;ve got large files and lots of &#8216;em. Besides, your styles should be reusable so you won&#8217;t have gigantic files.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/limitations-of-css-files-in-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jon Tan shows how to get @font-face to work on IE</title>
		<link>http://www.garrickcheung.com/css/jon-tan-shows-how-to-get-font-face-to-work-on-ie/</link>
		<comments>http://www.garrickcheung.com/css/jon-tan-shows-how-to-get-font-face-to-work-on-ie/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 04:00:20 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[font-face]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=113</guid>
		<description><![CDATA[If you&#8217;ve designed a website or built one based off of a designer&#8217;s vision, you&#8217;ll understand the frustration when they don&#8217;t want to use a common font and you have to explain why they should. There are a bunch of options of course, like sIFR and CSS image replacement. sIFR requires Flash and javascript, while [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve designed a website or built one based off of a designer&#8217;s vision, you&#8217;ll understand the frustration when they don&#8217;t want to use a <a href="http://www.ampsoft.net/webdesign-l/WindowsMacFonts.html" target="_blank">common font</a> and you have to explain why they should. There are a bunch of options of course, like <a href="http://wiki.novemberborn.net/sifr" target="_blank">sIFR</a> and CSS image replacement. sIFR requires Flash and javascript, while CSS image replacement basically hides the text while an image with the text is placed in the background. Then there&#8217;s the CSS @font-face construct which allows you to use an actual font file. There are two different implementations used between IE and the other popular browsers, and a whole mess about using licensed fonts. <a href="http://jontangerine.com/log/2008/10/font-face-in-ie-making-web-fonts-work" target="_blank">Jon Tan informs us</a> by giving a brief background about using licensed fonts and clarifying how to use @font-face in IE. Be warned though; the implementation of using @font-face in IE requires IE conditional comments.</p>
<p>Thank you Jon, for such a great in-depth article. Really nice work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/jon-tan-shows-how-to-get-font-face-to-work-on-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
