<?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>Seifi.org &#187; css</title>
	<atom:link href="http://www.seifi.org/category/css/feed" rel="self" type="application/rss+xml" />
	<link>http://www.seifi.org</link>
	<description>A Web Development Blog by Joe Seifi - seifi.org</description>
	<lastBuildDate>Thu, 26 Jan 2012 01:08:13 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Yummy Yummy, New Delicious Design</title>
		<link>http://www.seifi.org/css/yummy-yummy-new-delicious-design.html</link>
		<comments>http://www.seifi.org/css/yummy-yummy-new-delicious-design.html#comments</comments>
		<pubDate>Fri, 01 Aug 2008 00:20:13 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[portals]]></category>
		<category><![CDATA[ui]]></category>
		<category><![CDATA[web2.0]]></category>

		<guid isPermaLink="false">http://www.seifi.org/?p=670</guid>
		<description><![CDATA[Looks like the long awaited web 2.0izing of the del.icio.us website is finally here. Very sleek and sexy is my first impression. Take a look at some of the older user interfaces to get a sense for how del.icio.us has evolved until now. Aside from the new look there are new features as well. The [...]]]></description>
			<content:encoded><![CDATA[<p>Looks like the <a href="http://www.techcrunch.com/2007/09/06/exclusive-screen-shots-and-feature-overview-of-delicious-20-preview/" target="_blank">long awaited</a> web 2.0izing of the del.icio.us website is <a href="http://www.delicious.com" target="_blank">finally here</a>. Very sleek and sexy is my first impression.</p>
<p><img src="http://www.seifi.org/wp-content/uploads/2008/07/new_delicious.jpg" alt="" title="New Delicious Homepage Design" width="450" height="278" class="alignnone size-full wp-image-671" /></p>
<p> Take a look at some of the <a href="http://www.flickr.com/photos/joshu/sets/72157600740166824/" target="_blank">older user interfaces</a> to get a sense for how del.icio.us has <a href="http://delicious.com/help/whatsnew" target="_blank">evolved</a> until now. Aside from the new look there are new features as well. The delicious dev team has supposedly completely rewritten the code base, to allow for a more scalable and spry tool.</p>
<p><strong>New features:</strong></p>
<p><img src="http://www.seifi.org/wp-content/uploads/2008/07/delicious_changes_animation.gif" alt="" title="delicious_changes_animation" width="250" height="154" class="alignnone size-full wp-image-672" align="left" hspace="20" /> <strong>Navigation</strong>: New simple CSS tabs with onclick drop down menus make is simple to find your tasty bookmarks. The navigation structures seems to borrow from Flickr. Search also comes with a simple drop down option list to find stuff in your bookmarks, network or everyone. </p>
<p><strong>Bookmarks</strong>: You have Title view, regular view and Full View options here. View your popular bookmarks to filter the good stuff and filter down more by choosing fresh only. </p>
<p><strong>Sidebar</strong>: is updated to show a relative set of tags related to your left content pane. </p>
<p><strong>Action Box</strong>: This light blue box in the sidebar shows the common tasks for the given page. </p>
<p><strong>Search URL</strong>: This is a reverse search for bookmarks and pulls in the ones with the given URL along with tags used for that URL by each user, broken down in chronological order. You can also view the notes added by each user to the given URL.</p>
<p><strong>Settings</strong>: The settings page is laid out with all the actions listed on one page, similar to a sitemap.</p>
<p><strong>Forums</strong>: There is a support forum that looks more like a categorized list of links than a forum. I like the non-cluttered design. Reminds me of Drupal.</p>
<p>As in the past <a href="http://delicious.com/help/api" target="_blank">their API</a> is still available for developer consumption.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/yummy-yummy-new-delicious-design.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Understanding &amp; Taming Collapsing Margins in CSS</title>
		<link>http://www.seifi.org/css/understanding-taming-collapsing-margins-in-css.html</link>
		<comments>http://www.seifi.org/css/understanding-taming-collapsing-margins-in-css.html#comments</comments>
		<pubDate>Sat, 19 Jul 2008 00:24:37 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.seifi.org/?p=664</guid>
		<description><![CDATA[The concept of collapsing margins is very simple but to fully understanding its behaviors in CSS can be tough at first. When 2 or more vertical margins hit each other, they are combined (collapsed) to form just one margin. The largest of the margins is the one rendered in the flow. The formula in theory [...]]]></description>
			<content:encoded><![CDATA[<p>The concept of collapsing margins is very simple but to fully understanding its behaviors in CSS can be tough at first. When 2 or more vertical margins hit each other, they are combined (collapsed) to form just one margin. The largest of the margins is the one rendered in the flow. The formula in theory then, for the bottom or top margin of the adjoining boxes will be:</p>
<p><code>margin-top | margin-bottom: max( margin<sup>box 1</sup> ... margin<sup>box n</sup>)</code></p>
<p>When it comes to the real world there are 3 major categories of margin collapsing. So let&#8217;s figure out how these 3 types of collapsing work and how to tame them.</p>
<h3 style="clear:both;">1) Adjoining boxes of sibling elements:</h3>
<p>The bottom margin of an in-flow block-level element is always adjoining to the top margin of its next in-flow block-level sibling, unless that sibling has clearance.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"> &lt;div&gt;
  &lt;div&gt;content&lt;/div&gt;
  &lt;div&gt;content&lt;/div&gt;
 &lt;/div&gt;</pre></div></div>

<p><img src="http://www.seifi.org/wp-content/uploads/2008/07/sibling_collapsing.png" alt="" title="Sibling Collapsing" width="490" height="334" class="alignnone size-full wp-image-666" /></p>
<p>While margin collapsing is great for written text such as paragraphs and headings etc., it can get somewhat tricky if you&#8217;re trying to get pixel perfect spacing between your boxes, so there might come a time when you want to disable margin collapsing. Take a look at these examples that suggest ways of uncollapsing your margins.</p>
<div style="padding:0px;border:1px dashed black;margin:20px;background-color:#FEFFAF;overflow:hidden">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 child boxes inside a parent box, all 3 boxes have 20px margins, parent has <em>1px border</em> to avoid ancestor collapsing
</div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 child boxes have their top and bottom margins collapsed. Therefore the middle margin is 20px and not 40px. Most of the time this is what we want.
</div>
</div>
<div style="padding:0px;border:1px dashed black;margin:20px;background-color:#FEFFAF;overflow:hidden">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;float:left;clear:both">
2 child boxes inside a parent box, all have 20px margins, parent has <em>1px padding</em> to avoid ancestor collapsing</div>
<div style="padding:0px;border:0px dashed black;margin:0px;background-color:#BFFFFF;clear:left"></div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;float:left;clear:both;">
2 child boxes are this time <em>floated left and cleared</em>. Additionally clearing divs are added for Internet Explorer support. This method gives us 40px in the middle by disabling margin collapsing of the two siblings.
</div>
<div style="padding:0px;border:0px dashed black;margin:0px;background-color:#BFFFFF;clear:left"></div>
</div>
<div style="padding:0px;border:1px dashed black;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 child boxes inside a parent box, all have 20px margins, parent has <em>1px padding</em> to avoid ancestor collapsing
</div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;display:inline-block;">
This time we give the 1st child box a <em>display of inline-block</em> which is supposed to make its margins not collapse. While this inline-block behavior works like a charm in compliant browsers, unfortunately it does not work in IE7.
</div>
</div>
<div style="padding:0px;border:1px dashed black;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 child boxed inside a parent box, all have 20px margins, parent has <em>1px padding</em> to avoid ancestor collapsing
</div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;display:inline-block;display:inline-table;">
Finally this we use a <em>display of inline-table</em> on the first child box. This behavior works in IE7 and FF2 and above. Although inline-table does not break out of collapsing in IE7. You may also try overloading both properties on the element as a fail safe like: display:inline-block;display:inline-table;
</div>
</div>
<p>So it seems the only way to break out of collapsing that works in both IE and FF is our second example by using floats and clear combined. You might have noticed the above 4 boxes themselves also have 20px margins which have collapsed to form 20px margins within our 3 adjoining sections in the middle. </p>
<h3 style="clear:both;">2) Adjoining boxes of ancestor elements:</h3>
<p>The top or bottom margins of contained elements will always collapse together to form one margin. If the element&#8217;s margins are collapsed with its parent&#8217;s top margin, the top border edge of the box is defined to be the same as the parent&#8217;s. Below is the sample HTML and diagram and explanation of how to avoid this.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"> &lt;div&gt;
  &lt;div&gt;content&lt;/div&gt;
 &lt;/div&gt;</pre></div></div>

<p><img src="http://www.seifi.org/wp-content/uploads/2008/07/ancestor_collapsing.png" alt="" title="Ancestor Margin Collapsing" width="490" height="381" class="alignnone size-full wp-image-665" /><br />
Remember that collapsing only happens if the margins actually touch one another. In this case the inner box&#8217;s margin ends where the outer box&#8217;s margin starts, therefore they are touching. One easy way to avoid this type of margin collapsing is to add either vertical borders or vertical padding to the parent box. Take a look at these examples:</p>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 nested boxes, both have 20px margins, parent div has <em>no border or padding</em>. Note how the margins of both boxes collapse. The parent box takes over the margin of the child.
<p style="color:#5D478B;margin:10px;">You might be wondering, so why does the margin stick out of the outer div instead of being applied to inner div? Remember that the height of containers are calculated based on the the height if their children, and a block level element&#8217;s height is measured from its top border edge to its bottom border edge. So the outer div only honors the content height of its children when calculating its own height, and since margins are already collapsed, the inner margins will appear to protrude out of the parent.</p>
</div>
</div>
<div style="padding:0px;border:1px dashed black;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 nested boxes, both have 20px margins, parent has a <em>1px border</em>, which disables the collapsing.
</div>
</div>
<div style="padding:0px;border:1px solid transparent;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 nested boxes, both have 20px margins, parent has a <em>1px transparent border</em> for an invisible solution.
</div>
</div>
<div style="padding:1px;border:0px dashed black;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 nested boxes, both have 20px margins, parent has <em>1px padding</em> again for making it less visible in our UI.
</div>
</div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#FEFFAF;overflow:hidden;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
2 nested boxes, both have 20px margins, parent div has its <em>overflow hidden</em>. Great: Now we don&#8217;t have to add 2 extra pixels to our layout, but note that this method only works with ancestors.
</div>
</div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#FEFFAF;float:left;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;">
nested boxes, both have 20px margins, parent div is <em>floated left</em>. Works great if you are capable of using floats in your current flow.
</div>
</div>
<h3 style="clear:both;">3) Self collapsing boxes:</h3>
<p>Empty block level elements result in a special case of margin collapsing. Their top and bottom margins actually touch each other and they basically self destruct based on the rules of margin collapsing. According to the W3C: An element&#8217;s own margins are adjoining if the &#8216;min-height&#8217; property is zero, and it has neither top or bottom borders nor top or bottom padding, and it has a &#8216;height&#8217; of either 0 or &#8216;auto&#8217;, and it does not contain a line box, and all of its in-flow children&#8217;s margins (if any) are adjoining.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"> &lt;div&gt;
  &lt;div&gt;content&lt;/div&gt;
  &lt;div&gt;&lt;/div&gt;
  &lt;div&gt;content&lt;/div&gt;
 &lt;/div&gt;</pre></div></div>

<div style="padding:0px;border:1px dashed black;margin:20px;background-color:#FEFFAF;">
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;clear:both;">
3 child boxes inside a parent box, all have 20px margins, parent has <em>1px borders</em> to avoid ancestor collapsing
</div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#FEFFAF;"></div>
<div style="padding:0px;border:0px dashed black;margin:20px;background-color:#BFFFFF;clear:both;">there are 3 child boxes inside, but the middle child box collapses on itself, and then the surrounding 2 boxes collapse on its margins again, so the end result is that our empty box is not visible and basically does not affect the flow at all. Empty block level elements are often used for DOM manipulations and Ajax data storage and now we know why they don&#8217;t affect the layout.
</div>
</div>
<p>Another obvious way to break out of collapsing is changing the display to absolute. Finally, note that the margins of the root element box in any document never collapse. There are a few rules for negative margins when it comes to collapsing. I will try to write another post on this later.</p>
<p>I&#8217;ve created a <a href="http://seifi.org/wp-content/uploads/2008/07/collapsingmargins/">demo page here</a> with the above examples.</p>
<h3>References and Acknowledgments</h3>
<p><a target="_blank" href="http://www.w3.org/TR/CSS21/box.html#collapsing-margins">W3C Box Model</a> Collapsing Margins,<br />
<a target="_blank" href="http://www.andybudd.com/archives/2003/11/no_margin_for_error/">Andy Budd</a> No margin for error,<br />
<a target="_blank" href="http://www.researchkitchen.de/blog/archives/css-autoheight-and-margincollapsing.php">Research Kitchen</a> CSS Autoheight and Margin Collapsing,<br />
<a target="_blank" href="http://complexspiral.com/publications/uncollapsing-margins">Complex Spiral</a> Uncollapsing-margins,<br />
<a target="_blank" href="http://dev.l-c-n.com/IEW/collapsing-margins-inline-block.php">La Chatte Noire</a> tests: block formatting context, display:inline-block and margin collapsing</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/understanding-taming-collapsing-margins-in-css.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whats new in Safari 3.1 Web Inspector and Snippet Editor</title>
		<link>http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html</link>
		<comments>http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html#comments</comments>
		<pubDate>Fri, 21 Mar 2008 23:10:03 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.seifi.org/testing/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html</guid>
		<description><![CDATA[Safari 3.1 features improvements to the functionality for the Web Inspector developers tool. In now has an improved console for working with JavaScript and DOM, DOM inspector with CSS support, a nice Network analysis tool and search all built in. It is somewhat comparable to the FireBug plugin for FireFox so I will also make [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.seifi.org/browsers/safari-31-features.html">Safari 3.1 features improvements</a> to the functionality for the Web Inspector developers tool. In now has an improved console for working with JavaScript and DOM, DOM inspector with CSS support, a nice Network analysis tool and search all built in. It is somewhat comparable to the <a href="http://www.seifi.org/firebug/firebug_tips_and_tricks.html">FireBug plugin for FireFox</a> so I will also make some comparisons of their features.<br />
<span id="more-636"></span></p>
<h3>Web Inspector Overview</h3>
<p><img src='http://www.seifi.org/wp-content/uploads/2008/03/web_inspector_nav.gif' alt='Web Inspector Navigation' align="right" hspace="10" /> To get started open Web Inspector by going to Safari 3.1/Develop/Show Web Inspector and you will see the new window open up. The initial window is split up into a top row with navigation buttons and search box. The navigation buttons take you the the next and last actions you make within Web Inspector and come in handy when debugging. The left navigation lets you view and inspect the loaded web resources including Documents, StyleSheets, Images, Scripts, WebFonts, Databases and Other files, as well as buttons to load the Console and Network details. Ajax request and responses show up under the Other file category. If any errors are found, the number of errors are placed on the file name in the navigator. For example here, Safari has found 1 bug in the file diggthis.js The main content area shows you the web source details for viewing. JavaScript errors are marked with an orange pop, while HTML and CSS errors have a red color. If you want to attach Web Inspector to the bottom of your Safari Window click the small box on the bottom left corner of the window. I found this this to be a more usable placement.</p>
<h3>DOM Editing</h3>
<p>Clicking on any HTML Document on the left loads the source on the right. Documents can also be viewed as a DOM resrouce by clicking ont he DOM button on the top nav. (Note you have flip between DOM and Source view for HTML files.)</p>
<p><img src='http://www.seifi.org/wp-content/uploads/2008/03/webinspector_dom_search.gif' alt='DOM Editing' align="right" hspace="10" /> Searching supports DOM and CSS elements and you can nest your DOM element searches to filter out exactly what you&#8217;re looking for. For example #page a returns all anchor tags in the div with the page id. The corresponding display element in Safari is highlighted as you select DOM elements.</p>
<p>The right pane displays Styles, Metrics and Properties for seleted DOM elements. Styles show you both the computed style as well as all the defined style rules for that object. Like FireBug you can edit your CSS rules in real time in the Styles boxes for each CSS rule. To edit any CSS property double click the name or value and an edit box opens allowing you to type in your changes. This is great for testing out new ideas on the fly.</p>
<p>The metrics pane shows you the layout rules including offset, margin, border, padding, width and height for the element. Finally the Properties pane lists all of the DOM object properties that apply to the selected element.</p>
<h3>Downloadable Web Fonts</h3>
<p>If you are using downloadable web fonts the Fonts file group shows you a rendering of all the fonts that are loaded into the user&#8217;s browser.<img src='http://www.seifi.org/wp-content/uploads/2008/03/webfonts.gif' alt='Downloadble Web Fonts' /></p>
<h3>Client Side Databases</h3>
<p>Also if you are using the client side database features of HTML5, the Databases category will let your explore the databases loaded in the client along with the all the tables and rows in each client side database. From here you can also execute SQL queries against the databases.<img src='http://www.seifi.org/wp-content/uploads/2008/03/databases.gif' alt='Client Side Databases' /></p>
<h3>The Console</h3>
<p>The console feature lets you type in JavaScript commands and view JavaScript errors, along with HTML and CSS rule errors. Clicking on any error jumps to the file, but unfortunately doesn&#8217;t go the corresponding line. The console has an input area for testing out JavaScript and DOM commands on the bottom. There is in fact a console object and my tests showed that Safari supports only a few of the <a href="http://www.getfirebug.com/console.html" target="_blank">functions</a> for the console object. Here is a list of the FireBug console methods of which only a few are supported in Safari namely log, info, warn and error.</p>
<blockquote><p>
<strong>Supported methods:</strong><br />
log info warn error<br />
<strong>Unsupported methods:</strong><br />
debug assert dir dirxml trace group groupEnd time timeEnd profile profileEnd count
</p></blockquote>
<p><img src='http://www.seifi.org/wp-content/uploads/2008/03/console.gif' alt='Safari Console' /></p>
<h3>Network</h3>
<p>The network tab is actually quite nicely designed and show you what the transfer time or the transfer size for each resource and in total for the page. The capsule graph is color coded and breaks down the file types by Docs, CSS, Images, Script and Other. You can switch between time or size from the drop down. Web Inspector makes some suggestions as well for improving speed, for example here we see a recommendation to use file compression to save bandwidth. (I don&#8217;t really use this method now since IE6 is buggy with gzip deflation.) Click on any file to see the HTTP request and response header for that file.<br />
<img src='http://www.seifi.org/wp-content/uploads/2008/03/network.gif' alt='Network tool in Safari' /></p>
<h3>Snippet Editor</h3>
<p>The Snippet Editor is a little utility that allows you to enter blocks of HTML and CSS and have it rendered on the fly. It is quite useful for testing out your CSS and Layout in little chunks.<br />
<img src='http://www.seifi.org/wp-content/uploads/2008/03/snippet_editor.png' alt='Snippet Editor' /></p>
<p>Note: While using the Web Inspector and Snippet Editor, I came across numerous little annoying bugs and usability issues here and there. Also lots of features that I would expect are not there. For example you can not click on elements to inspect them, you can not add new style rules if they don&#8217;t exist already, and you can&#8217;t edit rules for CSS files loaded using @import. I would have to say that <a href="http://www.seifi.org/firebug/firebug_tips_and_tricks.html">FireBug</a> is a superior tool at this time for professional debugging, but Safari is about half way there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Safari 3.1 Features Review</title>
		<link>http://www.seifi.org/css/safari-31-features.html</link>
		<comments>http://www.seifi.org/css/safari-31-features.html#comments</comments>
		<pubDate>Wed, 19 Mar 2008 20:47:40 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[apple]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://www.seifi.org/browsers/safari-31-features.html</guid>
		<description><![CDATA[Apple released Safari 3.1 (525.13) for both Mac and Windows users today which comes with a bunch of changes and improvements over 3.0.x series. Here are the set of changes included in the new release. Developer Menu The first thing you will notice is the addition of the &#8220;Develop&#8221; menu (Preferences/Advanced/Show Develop menu in menu [...]]]></description>
			<content:encoded><![CDATA[<p>Apple released <a href="http://www.apple.com/safari/" target="_blank">Safari 3.1</a> (525.13) for both Mac and Windows users today which comes with a bunch of changes and <a href="http://docs.info.apple.com/article.html?artnum=307467" target="_blank">improvements</a> over 3.0.x series. Here are the set of changes included in the new release.</p>
<h3>Developer Menu</h3>
<p>The first thing you will notice is the addition of the &#8220;<strong>Develop</strong>&#8221; menu (Preferences/Advanced/Show Develop menu in menu bar) item with the following tasks:<br />
<span id="more-630"></span><br />
<img src="http://www.seifi.org/wp-content/uploads/2008/03/safari_develop_menu.png" title="Safari Developer Menu" alt="Safari Developer Menu" align="right" hspace="15" vspace="5" /> Open Page with: (Other browsers installed on your system including FireFox, Internet Explorer, Opera)</p>
<p>User Agent: Set you user agent from the list of options, or enter your own user-agent. Finally! This was previously part of the hidden debug menu and you had no way of specifying a custom user-agent. The other exciting additions here are the ability to set your user-agent as Mobile Safari 1.1.3 for either iPhone or the iPod touch.</p>
<p>You can also pull up the Web Inspector, Error console, Network Timeline and a Snippet Editor. Lastly the Developer menu allows you to disable various browser features such as Caches, Images, CSS Styles, JavaScript, Runaway JavaScript Timers, and Site-Specific Hacks. You can now also edit CSS in the Web Inspector. More on these in a <a href="http://www.seifi.org/testing/whats-new-in-safari-31-web-inspector-and-sinppet-editor.html">later post</a>.</p>
<h3>Standards Support</h3>
<p>Support for <a href="http://www.w3.org/TR/css3-webfonts/" target="_blank">CSS 3 web fonts</a> using CSS @font-face rules. check out <a href="http://www.alistapart.com/articles/cssatten" target="_blank">what can be done</a> with downloadable fonts in these working samples <a href="http://www.alistapart.com/d/cssatten/heid.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/poen.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/nels.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/stef.html" target="_blank">here</a>, <a href="http://www.alistapart.com/d/cssatten/blok.html" target="_blank">here</a>, and <a href="http://www.alistapart.com/d/cssatten/drim.html" target="_blank">here</a>. The CSS and a sample web font are show below. If you are using Safari 3.1 you should see a cool font.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #a1a100;">@font-face {</span>
  <span style="color: #000000; font-weight: bold;">font-family</span><span style="color: #00AA00;">:</span> <span style="color: #ff0000;">&quot;Acorn Initials&quot;</span><span style="color: #00AA00;">;</span>
  src<span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>http<span style="color: #00AA00;">:</span>//www<span style="color: #6666ff;">.domain</span>.com/Acorn___.ttf<span style="color: #00AA00;">&#41;</span> format<span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;truetype&quot;</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<style type="text/css" media="all">
@import "/wp-content/uploads/2008/03/webfonts.css";
</style>
<h1 id="webfonts">Safari 3.1</h1>
<p>Support for CSS <a href="http://webkit.org/blog/130/css-transforms/" target="_blank">transforms</a> and <a href="http://webkit.org/blog/138/css-animation/" target="_blank">transitions</a>. Below are some demos of these.</p>
<div style="width:85%;margin:0 auto 10px auto;padding:8px;">
<img hspace="20" vspace="5" align="left" src="http://www.seifi.org/wp-content/uploads/2008/03/safari_logo.png" alt="Safari 3.1" style="-webkit-transition:-webkit-transform 1.5s ease-in;" onclick="this.style.webkitTransform='rotate(1440deg)';" /> Here is a sample of the -webkit transform CSS which is now supported by Safari 3.1. Click on the Safari logo to rotate it 1440 degrees.<br />
<br style="clear:both" /></p>
<p><img hspace="20" vspace="5" align="left" src="http://www.seifi.org/wp-content/uploads/2008/03/safari_logo.png" alt="Safari 3.1" style="-webkit-transform: skew(35deg, 0deg);" /> The following Safari logo is skewed 35 degrees using -webkit-transform: skew(45deg, 0deg).<br />
<br style="clear:both" /></p>
<p><img hspace="20" vspace="5" align="left" src="http://www.seifi.org/wp-content/uploads/2008/03/safari_logo.png" alt="Safari 3.1" style="" onmouseover="this.style.webkitTransform='scale(1.3)'" onmouseout="this.style.webkitTransform='scale(1)'" /> The following image changes its scale using -webkit transform:scale() to zoom in 30% when you mouse over it.<br />
<br style="clear:both" />
</div>
<p>Support for <a href="http://www.whatwg.org/specs/web-apps/current-work/" target="_blank">HTML 5</a> &lt;<a href="http://www.whatwg.org/specs/web-apps/current-work/#video" target="_blank">video</a>&gt; and &lt;<a href="http://www.whatwg.org/specs/web-apps/current-work/#audio" target="_blank">audio</a>&gt; elements. Watch out Adobe and Flash. Here is a <a href="http://webkit.org/blog/140/html5-media-support/" target="_blank">demo</a> of the video tag. There is also added support for SVG images in &lt;img&gt; elements and CSS images and SVG advanced text.</li>
<p>Support for <a href="http://www.whatwg.org/specs/web-apps/current-work/#offline" target="_blank">offline</a> storage for Web applications in <a href="http://www.whatwg.org/specs/web-apps/current-work/#sql" target="_blank">SQL databases</a>. That means you can now store your databases locally on the client&#8217;s machine. Here&#8217;s some sample JavaScript to do the client side databases. Check out <a href="http://webkit.org/misc/DatabaseExample.html" target="_blank">this demo</a> that shows you how it works.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">database.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SELECT * FROM test&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result1<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">// do something with the results</span>
   database.<span style="color: #660066;">executeSql</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;DROP TABLE test&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>result2<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #006600; font-style: italic;">// do some more stuff</span>
     <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;My second database query finished executing!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>&nbsp;<br />
Running the <a href="http://www.css3.info/selectors-test/" target="_blank">CSS3 Selector tests</a> reveals that Safari 3.1 has full support for CSS3 Selectors while FireFox 2 and IE 7 are still playing catch up.<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/03/css3_support.png" alt="JavaScript Test Results" /></p>
<h3>Performance Improvements</h3>
<p>Apple claims that Safari 3.1 &#8220;executes JavaScript up to 6 times faster than Internet Explorer 7 and up to 4 times faster than Firefox 2&#8243;. Performance measured in seconds. Testing conducted by Apple in March 2008 on a 2.4GHz Intel Core 2 Duo-based iMac system running Windows XP Professional SP2, configured with 1GB of RAM and an ATI Radeon HD 2600 with 256MB of VRAM. HTML and JavaScript benchmarks based on VeriTest’s iBench Version 5.0 using default settings. Testing conducted with a beta version of Safari; all other browsers were shipping versions. Performance will vary based on system configuration, network connection, and other factors.&#8221; I tested IE7, FF2, and Safari 3.1 with 3 JavaScript performance testers and the Acid 3 test kit. The tools used are<br />
1. <a href="http://acid3.acidtests.org/" target="_blank">Acid3</a> tests.<br />
2. <a href="http://www.jorendorff.com/articles/javascript/speed-test.html" target="_blank">JavaScript speed test</a> written by Jason Orendorff<br />
3. <a href="http://webkit.org/perf/sunspider-0.9/sunspider.html" target="_blank">SunSpider</a> test kit from WebKit.org<br />
4. <a href="http://mootools.net/slickspeed/" target="_blank">slickspeed</a> test from Mootools.net</p>
<p>Here are the results in milliseconds from the tests which seem to agree with the results found by Apple. You can see that Safari 3.1 does in fact have a much more efficient JavaScript processing engine, and is three quarters of the way there when comes to passing the Acid3 tests.<br />
<img src="http://www.seifi.org/wp-content/uploads/2008/03/js_test_results.png" alt="JavaScript Test Results" /><br />
<small>Detail links at SunSpider: &nbsp; <a target="_blank" href="http://webkit.org/perf/sunspider-0.9/sunspider-results.html?%7B%223d-cube%22:%5B581,511,611,531,541%5D,%223d-morph%22:%5B561,591,591,631,611%5D,%223d-raytrace%22:%5B701,691,701,711,711%5D,%22access-binary-trees%22:%5B691,701,701,590,701%5D,%22access-fannkuch%22:%5B1132,1122,1102,1072,1362%5D,%22access-nbody%22:%5B570,561,550,550,1071%5D,%22access-nsieve%22:%5B571,571,571,571,1082%5D,%22bitops-3bit-bits-in-byte%22:%5B561,560,561,561,1152%5D,%22bitops-bits-in-byte%22:%5B621,621,621,631,1212%5D,%22bitops-bitwise-and%22:%5B731,731,741,731,852%5D,%22bitops-nsieve-bits%22:%5B581,581,581,581,621%5D,%22controlflow-recursive%22:%5B701,711,712,711,721%5D,%22crypto-aes%22:%5B561,571,561,561,571%5D,%22crypto-md5%22:%5B521,521,531,521,510%5D,%22crypto-sha1%22:%5B460,560,480,460,571%5D,%22date-format-tofte%22:%5B681,631,571,571,611%5D,%22date-format-xparb%22:%5B671,641,611,611,621%5D,%22math-cordic%22:%5B711,701,701,681,701%5D,%22math-partial-sums%22:%5B481,481,471,471,471%5D,%22math-spectral-norm%22:%5B541,521,530,530,530%5D,%22regexp-dna%22:%5B531,530,551,541,551%5D,%22string-base64%22:%5B19198,19338,19007,24445,32326%5D,%22string-fasta%22:%5B641,671,731,761,1312%5D,%22string-tagcloud%22:%5B3605,3705,3576,7872,3635%5D,%22string-unpack-code%22:%5B651,651,701,651,731%5D,%22string-validate-input%22:%5B10765,10736,10526,15542,21941%5D%7D">IE7</a> &nbsp;  &nbsp; <a  target="_blank" href="http://webkit.org/perf/sunspider-0.9/sunspider-results.html?%7B%223d-cube%22:%5B1342,1211,1192,1201,1212%5D,%223d-morph%22:%5B1742,1743,1762,1702,1733%5D,%223d-raytrace%22:%5B591,591,621,571,581%5D,%22access-binary-trees%22:%5B350,571,650,681,751%5D,%22access-fannkuch%22:%5B701,681,621,610,611%5D,%22access-nbody%22:%5B1442,1442,1412,1412,1412%5D,%22access-nsieve%22:%5B360,331,340,381,370%5D,%22bitops-3bit-bits-in-byte%22:%5B481,451,471,481,481%5D,%22bitops-bits-in-byte%22:%5B461,460,461,460,451%5D,%22bitops-bitwise-and%22:%5B3555,3565,3525,3455,4536%5D,%22bitops-nsieve-bits%22:%5B581,611,600,581,1152%5D,%22controlflow-recursive%22:%5B201,190,301,250,540%5D,%22crypto-aes%22:%5B531,511,511,501,681%5D,%22crypto-md5%22:%5B381,411,461,411,831%5D,%22crypto-sha1%22:%5B581,510,541,520,571%5D,%22date-format-tofte%22:%5B1402,1212,1042,1042,1121%5D,%22date-format-xparb%22:%5B2243,2123,2193,2053,2093%5D,%22math-cordic%22:%5B1272,1091,1192,1152,1221%5D,%22math-partial-sums%22:%5B842,841,821,841,821%5D,%22math-spectral-norm%22:%5B601,561,540,541,571%5D,%22regexp-dna%22:%5B1062,1161,1142,1141,1132%5D,%22string-base64%22:%5B1092,1092,1081,1092,1072%5D,%22string-fasta%22:%5B921,831,841,842,871%5D,%22string-tagcloud%22:%5B791,681,681,721,761%5D,%22string-unpack-code%22:%5B1111,1082,1132,1192,1072%5D,%22string-validate-input%22:%5B621,641,631,651,661%5D%7D">FireFox 2.2</a> &nbsp;  &nbsp; <a  target="_blank" href="http://webkit.org/perf/sunspider-0.9/sunspider-results.html?%7B%223d-cube%22:%5B250,300,280,281,171%5D,%223d-morph%22:%5B170,291,291,271,331%5D,%223d-raytrace%22:%5B321,271,271,271,290%5D,%22access-binary-trees%22:%5B211,191,180,190,210%5D,%22access-fannkuch%22:%5B511,451,490,500,501%5D,%22access-nbody%22:%5B280,280,311,321,291%5D,%22access-nsieve%22:%5B180,90,221,221,231%5D,%22bitops-3bit-bits-in-byte%22:%5B221,220,211,211,80%5D,%22bitops-bits-in-byte%22:%5B140,120,121,131,311%5D,%22bitops-bitwise-and%22:%5B361,390,381,381,370%5D,%22bitops-nsieve-bits%22:%5B241,251,250,250,240%5D,%22controlflow-recursive%22:%5B191,251,240,240,240%5D,%22crypto-aes%22:%5B221,251,250,250,250%5D,%22crypto-md5%22:%5B231,240,240,150,251%5D,%22crypto-sha1%22:%5B250,90,250,210,100%5D,%22date-format-tofte%22:%5B350,350,291,301,331%5D,%22date-format-xparb%22:%5B370,370,431,381,381%5D,%22math-cordic%22:%5B391,411,310,420,410%5D,%22math-partial-sums%22:%5B330,341,421,320,311%5D,%22math-spectral-norm%22:%5B280,280,201,291,201%5D,%22regexp-dna%22:%5B491,491,550,480,441%5D,%22string-base64%22:%5B240,241,261,230,220%5D,%22string-fasta%22:%5B360,350,371,331,330%5D,%22string-tagcloud%22:%5B271,251,251,270,281%5D,%22string-unpack-code%22:%5B270,350,350,280,280%5D,%22string-validate-input%22:%5B210,330,340,291,290%5D%7D">Safari 3.1</a></small></p>
<h3>Microsoft Windows</h3>
<ul>
<li>Improves Back/Forward performance</li>
<li>Supports signed Java applets</li>
<li>Shows Caps Lock icon in password fields</li>
<li>Adds support for showModalDialog</li>
<li>Localized in 16 languages</li>
<li>Adds support for International Domain Names</li>
<li>Improves handling of Japanese, Chinese, and Korean text</li>
<li>Contextual menu now allows opening a link in a window or tab</li>
<li>Improves pop-up blocking to work with plug-ins</li>
</ul>
<h3>Other Improvement</h3>
<ul>
<li>Double clicking on the Tab Bar opens new tab</li>
<li>Includes URL metadata when images are dragged or saved from browser</li>
<li>Opens Download and Activity window in current Space</li>
<li>Supports trackpad gestures for back, forward, and magnify on MacBook Air and compatible MacBook Pro computers</li>
<li>Shows Caps Lock icon in password fields</li>
<li><a href="http://docs.info.apple.com/article.html?artnum=307563" target="_blank">13 Security Fixes</a></li>
<li>Increased site compatibility</li>
<li>Improved application stability</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/safari-31-features.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating Thumbnails Using the CSS Clip Property</title>
		<link>http://www.seifi.org/css/creating-thumbnails-using-the-css-clip-property.html</link>
		<comments>http://www.seifi.org/css/creating-thumbnails-using-the-css-clip-property.html#comments</comments>
		<pubDate>Sun, 13 May 2007 22:06:18 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://www.seifi.org/css/creating-thumbnails-using-the-css-clip-property.html</guid>
		<description><![CDATA[One of the least used properties in CSS is the Clip property. Clip is part of the visual effects module of CSS 2.1 and its job is to place a visible window on top of an object that is being clipped. It is useful for clipping images and creating thumbnails without having to create additional [...]]]></description>
			<content:encoded><![CDATA[<p>One of the least used properties in CSS is the Clip property. Clip is part of the visual effects module of <a href="http://www.w3.org/TR/CSS21/">CSS 2.1</a> and its job is to place a visible window on top of an object that is being clipped. It is useful for clipping images and creating thumbnails without having to create additional files. This trick can be used to create square thumbnails, or to create other varieties of thumbnails without actually duplicating files on the server. Here is the rundown.<br />
<span id="more-553"></span><br />
Clippings are currently only offered in the shape of a rectangle but more shapes might be supported in the future. You can create a rectangle clipping using the <em>rect</em> shape. Using <em>rect</em> requires four coordinates Top, Right, Bottom, Left (TRBL). Let&#8217;s take a closer look at how clip calculates the clipping region since it tends to cause some confusion. Keep in mind that the bottom starts from the top, and the right starts from the left.</p>
<div style="background:url(http://www.seifi.org/wp-content/uploads/2007/05/clip_castle.jpg) top left no-repeat;width:300px;height;225px;">
<img src="http://www.seifi.org/wp-content/uploads/2007/05/clip_overlay.gif" width="300" height="225" alt="CSS Clip" />
</div>
<h3>Example</h3>
<p>Here is a sample image we want to clip:<br />
<img src='http://www.seifi.org/wp-content/uploads/2007/05/castle.jpg' alt='Castle' /></p>
<p>The CSS and HTML look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clipwrapper&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clip&quot;</span>&gt;</span>
     <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;castle.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.clipwrapper<span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">225px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.<span style="color: #000000; font-weight: bold;">clip</span><span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">clip</span><span style="color: #00AA00;">:</span>rect<span style="color: #00AA00;">&#40;</span><span style="color: #933;">50px</span> <span style="color: #933;">218px</span> <span style="color: #933;">155px</span> <span style="color: #933;">82px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<blockquote><p>NOTE: The W3C <a href="http://www.w3.org/TR/CSS21/">recommendation</a> suggests using commas between the coordinates, however this is broken <a href="http://msdn2.microsoft.com/en-us/library/ms530748.aspx">in Internet Explorer</a>. Strangely using the commas in IE does not work when in standards-compliant mode, but it does work when in quirks mode. To alleviate this issue I am not using commas which seems to work in all browsers including FireFox.</p></blockquote>
<p>and the result looks like this:</p>
<div class="clipwrapper">
<div class="clip">
     <img src="http://www.seifi.org/wp-content/uploads/2007/05/castle.jpg" alt="CSS Clip" />
    </div>
</div>
<p style="clear:both" />
<p>Our class (.clip) sets the clipping region using the TRBL rotation syntax. I&#8217;m using pixels lengths but you can also try other lengths or percentages here and they can be positive or negative. You can also use <em>auto</em>, which would skip clipping that specific edge. You can also try nested clips. </p>
<p>The other important thing to note is that the clipping class position must be set to absolute for the clip property to work. Here, I have used a relatively positioned wrapper div to keep our image where we want. Also specifying the height of the container div keeps the next line from overlapping with the clipped areas.</p>
<h3>Removing the clipped areas</h3>
<p>Keep in mind that the size of the clipped image doesn not change, but you may want to get rid of the clipped off areas. This is easy to do using the top and left offsets. First we have to set the width and height of the container div to the size of the clipped image. Now we just add negative offsets to the top and left of the clipped div to match the top and left settings in the clipping class. So now our new classes are like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.clipout<span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">136px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.clipin<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">clip</span><span style="color: #00AA00;">:</span>rect<span style="color: #00AA00;">&#40;</span><span style="color: #933;">50px</span> <span style="color: #933;">218px</span> <span style="color: #933;">155px</span> <span style="color: #933;">82px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-50px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-82px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>and the result look like this:</p>
<div class="clipout">
<div class="clipin">
     <img src="http://www.seifi.org/wp-content/uploads/2007/05/castle.jpg" alt="CSS Clip" />
    </div>
</div>
<p></p>
<h3>Add Some Drop Shadow</h3>
<p>Finally to add some drop shadow to the clipped thumbnail I am using three wrapper divs with negative offsets of slightly varying background colors to create a shade effect. So our final HTML and CSS look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shade1&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shade2&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;shade3&quot;</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clipout&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clipin&quot;</span>&gt;</span>
     <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;castle.jpg&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
   <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">.clipout<span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">136px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.clipin<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">clip</span><span style="color: #00AA00;">:</span>rect<span style="color: #00AA00;">&#40;</span><span style="color: #933;">50px</span> <span style="color: #933;">218px</span> <span style="color: #933;">155px</span> <span style="color: #933;">82px</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-50px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-82px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.shade1<span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">136px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#e8e8e8</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.shade2<span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">136px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#cbcbcb</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-2px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-2px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
.shade3<span style="color: #00AA00;">&#123;</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: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">136px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">105px</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#a0a0a0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">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;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>and here is the result:</p>
<div class="shade1">
<div class="shade2">
<div class="shade3">
<div class="clipout">
<div class="clipin">
     <img src="http://www.seifi.org/wp-content/uploads/2007/05/clip_castle.jpg" alt="CSS Clip" />
    </div>
</p></div>
</div>
</div>
</div>
<p></p>
<p>The CSS3 working draft includes a <a href="http://www.w3.org/TR/css3-box/#the-crop">crop</a> property which is very similar to the clip property but would also crop off the area we have removed, so that the original object is actually replaced with the cropped section. As far as I can see no browsers have implemented this property as of now.</p>
<style>
.shade1{
  width:136px;
  height:105px;
  background-color:#e8e8e8;
}
.shade2{
  position:relative;
  width:136px;
  height:105px;
  background-color:#cbcbcb;
  top:-2px;
  left:-2px;
}
.shade3{
  position:relative;
  width:136px;
  height:105px;
  background-color:#a0a0a0;
  top:-1px;
  left:-1px;
}
.clipout{
  position:relative;
  width:136px;
  height:105px;
  top:-1px;
  left:-1px;
}
.clipin{
  position:absolute;
  clip:rect(50px 218px 155px 82px);
  top:-50px;
  left:-82px;
}
.clipwrapper{
  height: 225px;
  position:relative;
}
.clip{
  position:absolute;
  clip:rect(50px 218px 155px 82px);
}
</style>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/creating-thumbnails-using-the-css-clip-property.html/feed</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
		<item>
		<title>How to Boost Your JavaScript and CSS Performance</title>
		<link>http://www.seifi.org/css/how_to_boost_your_javascript_and_css_performance.html</link>
		<comments>http://www.seifi.org/css/how_to_boost_your_javascript_and_css_performance.html#comments</comments>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.seifi.org/css/how_to_boost_your_javascript_and_css_performance.html</guid>
		<description><![CDATA[Lines of markup code per website are growing at a hurried pace these days. JavaScript and CSS files are getting bigger by the day. But you want to keep your site lean and speedy and avoid from becoming slow and bloated. There are some basic techniques I use to optimize JavaScript files and the same [...]]]></description>
			<content:encoded><![CDATA[<p>Lines of markup code per website are growing at a hurried pace these days. JavaScript and CSS files are getting bigger by the day. But you want to keep your site lean and speedy and avoid from becoming slow and bloated. There are some basic techniques I use to optimize JavaScript files and the same ideas can be applied to CSS and HTML files as well. I&#8217;ll briefly cover 4 popular solutions, namely validating, joining, shrinking and compressing your markup source code.<span id="more-482"></span></p>
<h3><strong>1) Validate your code</strong></h3>
<p>Although JavaScript can be very forgiving when it comes to error handling, sloppy coding will come back to haunt you in the long run. So the first step is to validate your code. I use <a href="http://www.jslint.com/lint.html">JSLint</a> which scans JavaScript code for syntax errors and common mistakes and recommends fixes. JSLint piggy backs on <a href="http://www.mozilla.org/rhino/">Rhino</a> which is an implementation of JavaScript written in Java from <a href="http://www.mozilla.org/">Mozilla</a>. You can either use the <a href="http://www.jslint.com/">online version</a> or download and run the scanner locally. I prefer this local method which utilizes the <a href="http://www.java.com/">java runtime</a>.</p>
<p>To use <strong>JSLint</strong> locally:</p>
<ol>
<li>Download and unzip <a href="http://www.mozilla.org/rhino/download.html">Rhino</a> to a folder on your computer. You need <em>js.jar</em></li>
<li>Download and save the JSLint library file <a href="http://www.jslint.com/rhino/jslint.js"><em>jslint.js</em></a></li>
<li>Run JSLint in the Rhino Shell passing it a JavaScript file to scan. Here is the command I use assuming <em>js.jar</em>, <em>jslint.js</em>, and <em>MYBIG.js</em> are all in the same directory.</li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">java <span style="color: #660033;">-classpath</span> js.jar 
org.mozilla.javascript.tools.shell.Main 
jslint.js MYBIG.js</pre></div></div>

<p>You will then see a list of errors found by JSLint and suggestions for fixing your code. Some of the most common items are:</p>
<ul>
<li>Missing end of line semi-colon delimiters <font color="#800080">;</font><strong> </strong></li>
<li>Not using <em>dot notation</em> to reference DOM objects (ex. <font color="#800080">form['name'].input.value <font color="#000000">instead of</font> form.name.input.value</font> )</li>
<li>Using <font color="#800080">==</font> instead of <font color="#800080">===</font> for comparing with null, undefined, booleans, zero and &#8220;&#8221;</li>
<li>Variable scope issues caused by declaring variables inside of loops instead of declaring them first in functions definitions.</li>
<li>Not using curly braces in your conditional blocks. So make a point to always do <font color="#800080">If(x){doX();}else{doY();}</font> even if you have one liners.</li>
<li>Stay away from using <font color="#800080"><strike>eval()</strike></font> or <font color="#800080"><strike>with().</strike></font><font color="#000000"> eval is evil <img src='http://www.seifi.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </font></li>
<li>Create your arrays using literal notation <font color="#800080">[]</font> instead of <font color="#800080"><strike>new Array()</strike></font></li>
<li>Create your objects using <font color="#800080">{}</font> instead of <font color="#800080"><strike>new Object()</strike></font></li>
<li>Avoid using <font color="#800080"><strike>javascript:function()</strike></font> in URLs</li>
<li>You can read more suggestions in the JSLint <a href="http://www.jslint.com/lint.html">docs</a>.</li>
</ul>
<h3><strong>2) Join your files</strong></h3>
<p>If you have five separate CSS files and three different JavaScript files, your server has to answer 8 HTTP requests per client. Each request requires additional processing and slows down your page loading. By concatenating your CSS and JavaScript files to only 2, you should see page load time improvements, especially when client requests are coming from distant networks.</p>
<p>Another tip that I have seen is to move your JavaScript include tags to the very bottom of the page, right before the &lt;/body&gt; tag. This will allow the browser to draw the DOM before loading your library files and the page will appear to load faster.</p>
<p>So after your various source files are nice and lint free, and combined into a single library file you are ready to start shrinking.</p>
<h3><strong>3) Shrink your library</strong></h3>
<p>Before shipping your code, shrink it. JavaScript and CSS files are not compiled and they contain lots of wasted whitespace which are nice to have when you&#8217;re coding but serve no benefit to the user of your website. There are four different tools you can use to filter out the unnecessary bits from your JavaScript and CSS files, and for the most part they are doing the same thing. I personally use ShrinkSafe which is a happy safe medium. The reason is that this tool does not mangle your code so that its API will stay in tact. If you choose to use a decryption based method to obfuscate your code, it can have harmful side effects. First, the size of the encrypted file can in some cases actually be larger than the original! Second, your scripted API can get mangled, forcing you to update all external pointers to your code. If you have any clients who use your API via JavaScript, you should obviously take great caution in using encryption methods.</p>
<blockquote><p><u>Caution:</u> As always, backup your code before making changes to them using these tools! There is no undo!</p></blockquote>
<h4><strong>JavaScript Shrinking</strong></h4>
<ol>
<li><a href="http://javascript.crockford.com/jsmin.html">JSMin</a> removes extra white-space and comments. It also reduces the line count by increasing the maximum line width. The result a bit uglier and harder to read and debug but also a bit smaller. Unlike ShrinkSafe, though JSMin does not edit your function arguments. You can <a href="http://javascript.crockford.com/jsmin.html">download</a> it in a variety of flavors. Here is a DOS executable version and the command to run it.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">jsmin <span style="color: #000000; font-weight: bold;">&lt;</span>big.jsb <span style="color: #000000; font-weight: bold;">&gt;</span>min_jsmin.js <span style="color: #ff0000;">&quot;(c)2007 CORP&quot;</span></pre></div></div>

</li>
<li><a href="http://alex.dojotoolkit.org/shrinksafe/">ShrinkSafe</a> removes extra white-space and comments, but keeps one statement per line which is easy on the eye if you decide to edit your shrunk file. It also shrinks function arguments by replacing them with consecutive _## values which tends to reduce the files size some more. Download the jar file <a href="http://svn.dojotoolkit.org/dojo/trunk/buildscripts/lib/custom_rhino.jar">here</a> and run it as follows:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">java <span style="color: #660033;">-jar</span> custom_rhino.jar <span style="color: #660033;">-c</span> big.js <span style="color: #000000; font-weight: bold;">&gt;</span> 
min_shrinksafe.js <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></div></div>

</li>
<li><a href="http://dean.edwards.name/packer/">Packer</a> has a few options you can choose to minify your scripts. The normal option removes extra white-space and puts the entire file in one super long line. You can also choose to shrink  function as well as encode your script using a base62 algorithm. You can <a target="_blank" href="http://dean.edwards.name/packer/">try it</a> online. Although your file size is considerably smaller, depending on the complexity and cleanliness of your code (see JSLint above) using the two options in Packer might introduce errors with your code. In my case I had no problems with them.</li>
<li><a href="http://hometown.aol.de/_ht_a/memtronic/">MemTronic</a> &#8211; Hardcore shrinkers out there can try this online tool which produces the smallest file size in my tests. Be warned that this is only for the braveheart coders, has some known issues and may have some side effects.</li>
</ol>
<p>I have run Prototype.js against these 4 tools and the results are shown below. The results show that you can save at least 20% on your file size without compromising much stability.</p>
<table border="0" width="90%" cellPadding="0" cellSpacing="1" class="gridtable">
<tr>
<th>Tool Used</th>
<th>File Name</th>
<th>File Size</th>
<th>Lines</th>
<th>Reduced</th>
</tr>
<tr>
<td>None</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/prototype.js">prototype.js</a></td>
<td>71,260</td>
<td>2514</td>
<td>Original</td>
</tr>
<tr>
<td>JSMin</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_jsmin.js">min_jsmin.js</a></td>
<td>54,035</td>
<td>183</td>
<td>-24%</td>
</tr>
<tr>
<td>Shrinksafe</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_shrinksafe.js">min_shrinksafe.js</a></td>
<td>50,725</td>
<td>1972</td>
<td>-29%</td>
</tr>
<tr>
<td>Packer</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_packer_noptions.js">min_packer_noptions.js</a></td>
<td>53,455</td>
<td>1</td>
<td>-25%</td>
</tr>
<tr>
<td>Packer</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_packer_shrunkvars.js">min_packer_shrunkvars.js</a></td>
<td>43,903</td>
<td>1</td>
<td>-38%</td>
</tr>
<tr>
<td>Packer</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_packer_encoded.js">min_packer_encoded.js</a></td>
<td>29,273</td>
<td>1</td>
<td>-59%</td>
</tr>
<tr>
<td>Packer</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_packer_both.js">min_packer_both.js</a></td>
<td>27,634</td>
<td>1</td>
<td>-61%</td>
</tr>
<tr>
<td>MemTronic</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_memtronic_compress.js">min_memtronic_compress.js</a></td>
<td>24,483</td>
<td>1</td>
<td>-66%</td>
</tr>
</table>
<h4><strong><strong>CSS Shrinking</strong></strong></h4>
<ol>
<li><a href="http://www.cleancss.com/">Clean CSS</a> &#8211; This tool creates the best results, reducing the files size while maintaining a nicely formatted and readable CSS file. It has a plethora of options to choose from as well. For example, you can sort the properties of all the selectors which is a godsend for neat-freaks like me. It will also compress your css by converting possible properties to use shorthand notations. You can choose to save your comments.</li>
<li><a href="http://www.cssoptimiser.com/">CSS Optimiser</a> &#8211; This tool only has one option which is to remove line breaks or not. Does a good job however the final file size does not decrease much if you don&#8217;t pick that option, which makes the css tough to read.</li>
<li><a href="http://iceyboard.no-ip.org/projects/css_compressor">Icey CSS Compressor</a> &#8211;  Here is another powerful tool with lots of options to go around. Here are a few of them: Convert colors to hex, combine identical rules, combine properties, combine selectors, remove useless padding and margin. It also outputs in a nice colorful format for you. However there is no option to keep line breaks in tact so you get the output all in one line, and in my case this actually created an error.</li>
<li><a href="http://flumpcakes.co.uk/css/optimiser/">Flumpcakes Optimiser</a> &#8211; This tool has a few useful options such as combining backgrounds, fonts, lists, borders, and style which appear in multiple places. It can also convert RGB to hex and absolute to relative.</li>
</ol>
<p>I ran the CSS from <a href="http://reader.earthlink.net/">EarthLink ReaDeR</a> through the top four tools and the results are shown below.</p>
<table border="0" width="90%" cellPadding="0" cellSpacing="1" class="gridtable">
<tr>
<th>Tool Used</th>
<th>File Name</th>
<th>File Size</th>
<th>Lines</th>
<th>Reduced</th>
</tr>
<tr>
<td>None</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/reader.css">reader.css</a></td>
<td>12,875</td>
<td>227</td>
<td>Original</td>
</tr>
<tr>
<td>Clean CSS</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_cleancss.css">min_cleancss.css</a></td>
<td>11,735</td>
<td>940</td>
<td>-2%</td>
</tr>
<tr>
<td>CSS Optimiser</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_cssoptimiser.css">min_cssoptimiser.css</a></td>
<td>11,304</td>
<td>2</td>
<td>-2%</td>
</tr>
<tr>
<td>Icey CSS Compressor</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_icey.css">min_icey.css</a></td>
<td>10,383</td>
<td>1</td>
<td>-3%</td>
</tr>
<tr>
<td>Flumpcakes Optimisor</td>
<td><a href="http://seifi.org/wp-content/uploads/2007/04/min_flumpcakes.css">min_flumpcakes.css</a></td>
<td>12,885</td>
<td>796</td>
<td>0%</td>
</tr>
</table>
<p><!--adsense#post--></p>
<h3><strong>4) Compress your files</strong></h3>
<p>The HTTP implementation covers accept-encoding and content-encoding in detail and most browsers today support these methods. Basically when a browser sends a request, it tells the server it would like to have the file back in a compressed format such as gzip or deflate. The server then compresses the file and sends it back, and the browser decompresses the file and renders it in the browser. The most common format used today is GZip. Here is how to setup GZip in two popular web servers.</p>
<ol>
<li><strong>Apache &amp; mod_gzip</strong> &#8211; If you are running on Apache and have already compiled it with mod_gzip you can easily <a href="http://www.schroepl.net/projekte/mod_gzip/config.htm">configure</a> gzip compression by adding these lines to an .htaccess file placed in your web root or your http.conf file.

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mod_gzip_on Yes
mod_gzip_item_include <span style="color: #c20cb9; font-weight: bold;">file</span> \.php$
mod_gzip_item_include <span style="color: #c20cb9; font-weight: bold;">file</span> \.html$
mod_gzip_item_include mime ^text<span style="color: #000000; font-weight: bold;">/</span>html$
mod_gzip_item_include <span style="color: #c20cb9; font-weight: bold;">file</span> \.txt$
mod_gzip_item_include mime ^text<span style="color: #000000; font-weight: bold;">/</span>plain$
mod_gzip_item_include <span style="color: #c20cb9; font-weight: bold;">file</span> \.css$
mod_gzip_item_include mime ^text<span style="color: #000000; font-weight: bold;">/</span>css$
mod_gzip_item_include <span style="color: #c20cb9; font-weight: bold;">file</span> \.js$
mod_gzip_item_include mime ^application<span style="color: #000000; font-weight: bold;">/</span>x-javascript$
mod_gzip_item_exclude mime ^image<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>If you don&#8217;t have access to your .htaccess file but do have php compiled with the <a href="http://us2.php.net/manual/en/ref.zlib.php">zlib</a> module you can rename your javascript files to .php extensions and add this to the top of your file.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">ob_start</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ob_gzhandler&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-type: text/javascript;charset:UTF-8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: must-revalidate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$offset</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">60</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">24</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">365</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// one year</span>
<span style="color: #000088;">$ExpStr</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Expires: &quot;</span> <span style="color: #339933;">.</span>
<span style="color: #990000;">gmdate</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D, d M Y H:i:s&quot;</span><span style="color: #339933;">,</span>
<span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #000088;">$offset</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; GMT&quot;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ExpStr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</li>
<li><strong>JBoss and Tomcat</strong> &#8211; To enable compression in a J2EE environment running Tomcat within <a href="http://www.jboss.com/">JBoss</a>, you can now enable compression by editing your server.xml that sits in the tomcat.sar folder. Just add these attributes to the Connector node:

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;connector</span> <span style="color: #000066;">port</span>=<span style="color: #ff0000;">&quot;8080&quot;</span> <span style="color: #000066;">compression</span>=<span style="color: #ff0000;">&quot;on&quot;</span> </span>
<span style="color: #009900;"><span style="color: #000066;">compressionMinSize</span>=<span style="color: #ff0000;">&quot;300&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">noCompressionUserAgents</span>=<span style="color: #ff0000;">&quot;gozilla, traviata&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">compressableMimeType</span>=<span style="color: #ff0000;">&quot;text/html,text/xml,text/css,</span>
<span style="color: #009900;">text/javascript, application/x-javascript,</span>
<span style="color: #009900;">application/javascript&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

</li>
</ol>
<h3><strong>The Results</strong></h3>
<p>Finally, here are two pages that use the compressed versions of prototype.js and reader.css, one <a href="http://seifi.org/wp-content/uploads/2007/04/gzipped/index.php">with gzip compression enabled</a>, and the other <a href="http://seifi.org/wp-content/uploads/2007/04/nogzip/index.php">without gzip compression</a> enabled. Using the Net tab in <a href="http://www.seifi.org/node/477">FireBug</a> we can easily see that the gzipped version of both the CSS and JavaScript files actually result in less network traffic and faster loads times.</p>
<p>We cut our total throughput by 44 KB or 70%! Also the total load time is cut by 521ms or 51%, basically reduced from 1 second to half a second. If we do some quick math, for a website that gets 1,000,000 unique visitors per day, this is a daily savings of 44GB of bandwidth, and a total of about 145 precious hours saved.</p>
<table border="0" width="90%" cellPadding="0" cellSpacing="1" class="gridtable">
<tr>
<th>Size in KB</th>
<th>CSS</th>
<th>JavaScript</th>
<th>Total</th>
</tr>
<tr>
<td>No Compression</td>
<td>12KB</td>
<td>51KB</td>
<td>63KB</td>
</tr>
<tr>
<td>Gzipped</td>
<td>4KB</td>
<td>15KB</td>
<td>19KB</td>
</tr>
<tr>
<td>Reduction</td>
<td>8KB 67%</td>
<td>36KB 71%</td>
<td>44KB 70%</td>
</tr>
<tr>
<td colSpan="3">Savings for 1 mil uniques/day</td>
<td>44 GB</td>
</tr>
<tr>
<td colSpan="4" style="padding: 0px"><a href="http://seifi.org/wp-content/uploads/2007/04/nogzip/index.php"><img border="0" width="392" src="http://seifi.org/wp-content/uploads/2007/04/nogzip.gif" height="116" /></a></td>
</tr>
</table>
<p>
<p>&nbsp;</p>
<table border="0" width="90%" cellPadding="0" cellSpacing="1" class="gridtable">
<tr>
<th>Time in Milliseconds</th>
<th>CSS</th>
<th>JavaScript</th>
<th>Total</th>
</tr>
<tr>
<td>No Compression</td>
<td>281ms</td>
<td>741ms</td>
<td>1022ms</td>
</tr>
<tr>
<td>Gzipped</td>
<td>110</td>
<td>391</td>
<td>501ms</td>
</tr>
<tr>
<td>Reduction</td>
<td>171ms 61%</td>
<td>350ms 47%</td>
<td>521ms 51%</td>
</tr>
<tr>
<td colSpan="3">Savings for 1 mil uniques/day</td>
<td>145 Hrs.</td>
</tr>
<tr>
<td colSpan="4" style="padding: 0px"><a href="http://seifi.org/wp-content/uploads/2007/04/gzipped/index.php"><img border="0" width="392" src="http://seifi.org/wp-content/uploads/2007/04/gzipped.gif" height="116" /></a></td>
</tr>
</table>
<p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/how_to_boost_your_javascript_and_css_performance.html/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>CSS Shorthand for the Font Element</title>
		<link>http://www.seifi.org/css/css_shorthand_for_the_font_element.html</link>
		<comments>http://www.seifi.org/css/css_shorthand_for_the_font_element.html#comments</comments>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I am a firm believer in reducing code and optimizing page load to speed up browsing. CSS is one of those places where we can try to compress our code using shorthand notation. It is also much cooler and faster to write code once you learn all the shorthand tricks. The Font tag is one [...]]]></description>
			<content:encoded><![CDATA[<p>I am a firm believer in reducing code and optimizing page load to speed up browsing. CSS is one of those places where we can try to compress our code using shorthand notation. It is also much cooler and faster to write code once you learn all the shorthand tricks. The Font tag is one of the trickiest shorthand notations around, and I have noticed that many people shy away from using this specific shorthand notation.<br />
<span id="more-472"></span></p>
<p>So, I decided to do a quick FONT tag shorthand lab and find out once and for all what we need to do to get this thing working properly. Below are 10 sample runs which have the porperties for the font tag applied in various orders.</p>
<style>#shorthand-font h1.f1{font: italic small-caps bold 14pt/1 arial;}  #shorthand-font h1.f2{font: arial italic small-caps bold 14pt/50px;}  #shorthand-font h1.f3{font: 14pt/1 arial italic small-caps bold;}  #shorthand-font h1.f4{font: bold 14pt/1 arial italic small-caps;}  #shorthand-font h1.f5{font: italic 14pt/1 small-caps bold arial;}  #shorthand-font h1.f6{font: italic bold 14pt/1 small-caps arial;}  #shorthand-font h1.f7{font: normal normal normal 14pt/1 arial;}  #shorthand-font h1.f8{font: 14pt/1 arial;}  #shorthand-font h1.f9{font: 14pt/80px;}  #shorthand-font h1.f10{font: arial;}  #shorthand-font h1{margin:20px 0 0 0;padding:0;} </style>
<div id="shorthand-font">
<h1 class="f1">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f1</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">italic</span> <span style="color: #993333;">small-caps</span> <span style="color: #993333;">bold</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> arial<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f2">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f2</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> arial <span style="color: #993333;">italic</span> <span style="color: #993333;">small-caps</span> <span style="color: #993333;">bold</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f3">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f3</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> arial <span style="color: #993333;">italic</span> <span style="color: #993333;">small-caps</span> <span style="color: #993333;">bold</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f4">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f4</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">bold</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> arial <span style="color: #993333;">italic</span> <span style="color: #993333;">small-caps</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f5">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f5</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">italic</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> <span style="color: #993333;">small-caps</span> <span style="color: #993333;">bold</span> arial<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f6">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f6</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">italic</span> <span style="color: #993333;">bold</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> <span style="color: #993333;">small-caps</span> arial<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f7">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f7</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span> <span style="color: #993333;">normal</span> <span style="color: #993333;">normal</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> arial<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f8">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f8</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span> arial<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f9">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f9</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> <span style="color: #933;">14pt</span>/<span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<h1 class="f10">CSS Font Shorthand</h1>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.f10</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span> arial<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

</div>
<p>&nbsp;</p>
<p><strong>Lessons Learned:</strong></p>
<ul>
<li>Order of the properties matters.</li>
<li>The correct order is <em>font:font-style | font-variant | font-weight | font-size | line-height | font-family</em></li>
<li>All modern browsers fully support CSS shorthand. </li>
<li>Both the font-size and the font-family are required.</li>
<li>The font-family must always be at the very end. </li>
<li>The font-size must come before the font-family. </li>
<li>The font-style, font-variant or font-weight commands are optional and will be defaulted to the value &#8220;normal&#8221; if left out.</li>
</ul>
<p><strong>Here is a CSS Font Shorthand Style Guide.</strong><br />
<img src='http://www.seifi.org/wp-content/uploads/2007/05/css_font_guide.gif' alt="CSS Font Shorthand Style Guide" width="513" height="230" alt="CSS Font Shorthand Style Guide" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/css_shorthand_for_the_font_element.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Cheaper and Prettier</title>
		<link>http://www.seifi.org/css/cheaper_and_prettier.html</link>
		<comments>http://www.seifi.org/css/cheaper_and_prettier.html#comments</comments>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Douglas Bowman's <a href="http://www.stopdesign.com/present/2004/sydney/beauty/">The Beauty and Business of CSS</a> slide show presents insight into how CSS can benefit both the user and the owner. Having looked at these pages makes me want to redo the theme for my page. I hope to have some time to do that pretty soon.

]]></description>
			<content:encoded><![CDATA[<p>Douglas Bowman&#8217;s <a href="http://www.stopdesign.com/present/2004/sydney/beauty/">The Beauty and Business of CSS</a> slide show presents insight into how CSS can benefit both the user and the owner. Having looked at these pages makes me want to redo the theme for my page. I hope to have some time to do that pretty soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/cheaper_and_prettier.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Efficiency Tips</title>
		<link>http://www.seifi.org/css/css_efficiency_tips.html</link>
		<comments>http://www.seifi.org/css/css_efficiency_tips.html#comments</comments>
		<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate>
		<dc:creator>Joe Seifi</dc:creator>
				<category><![CDATA[css]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[A good <a href="http://www.communitymx.com/content/article.cfm?cid=90F55">article</a> about the writing compact and smart css. Covers shorthand, the clock, and default values.
]]></description>
			<content:encoded><![CDATA[<p>A good <a href="http://www.communitymx.com/content/article.cfm?cid=90F55">article</a> about the writing compact and smart css. Covers shorthand, the clock, and default values.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.seifi.org/css/css_efficiency_tips.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.853 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-02-03 19:15:27 -->

