<?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>Big Red Tin &#187; CSS</title>
	<atom:link href="http://bigredtin.com/tag/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigredtin.com</link>
	<description>Thoughts about the web and business from the large pantry</description>
	<lastBuildDate>Tue, 07 Sep 2010 02:53:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Delay Print Stylesheets Plugin</title>
		<link>http://bigredtin.com/behind-the-websites/delay-print-css-plugin/</link>
		<comments>http://bigredtin.com/behind-the-websites/delay-print-css-plugin/#comments</comments>
		<pubDate>Fri, 27 Aug 2010 02:17:29 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bigredtin.pressgiant.net/?p=739</guid>
		<description><![CDATA[A few weeks ago I wrote a post in which I adapted an idea from a zOompf article to delay the loading of print stylesheets until after a web page has fully rendered. I've decided to convert the code from the original post into a plugin and add it to the WordPress plugin directory.]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I wrote a post in which I <a title="adapted an idea from a zOompf article" href="http://bigredtin.com/behind-the-websites/delay-loading-of-print-css/">adapted an idea from a zOompf article</a> to delay the loading of print stylesheets until after a web page has fully rendered. I finished that post with the following point/question:</p>
<blockquote><p>Another question to ask is whether all this is actually worth the effort – even when reduced through automation. On Big Red Tin, the print.css is 595 bytes, the delay in rendering is negligible.</p></blockquote>
<p>Chris and Jeff at <a title="Digging into WordPress" href="http://digwp.com">Digging into WordPress</a> picked up the article and posted it on their site. In turn it was picked up elsewhere and became the surprise hit of the summer at Big Red Tin. Not bad when one is shivering through a bitter Melbourne winter.</p>
<p>As a result of the interest, I decided to convert the code from the original post into a plugin and add it to the WordPress plugin directory.</p>
<h4>Further Testing</h4>
<p>As I warned in the original article, I&#8217;d tested the code in very limited circumstances and found it had worked. Fine for a code sample but not enough for a sub version-1.0-release plugin. Additional testing showed:</p>
<ol>
<li>Stylesheets intended for IE, through conditional comments, were loading in all browsers</li>
<li>When loading multiple stylesheets, the correct order was not maintained in all browsers</li>
</ol>
<p>If jQuery was available I wanted to use it for JavaScript event management otherwise I&#8217;d use purpose-written JavaScript. There&#8217;s no point, after all, of worrying about the rendering delay caused by 600-1000 bytes only to load a 71KB (or 24KB <a title="gzipped" href="http://developer.yahoo.net/blog/archives/2007/07/high_performanc_3.html">gzipped</a>) file in its place.</p>
<p>Other things I wanted to do included:</p>
<ol>
<li>Put the PHP in a class to reduce the risk of clashing function/class names</li>
<li>Put the JavaScript in its own namespace</li>
<li>Keep the output code as small as possible</li>
</ol>
<p>To support conditional comments for IE required adding each stylesheet within a separate &lt;script&gt; tag, using this method the output HTML takes the following form:</p>
<pre><code>&lt;script&gt;
  // add global print.css
&lt;/script&gt;
&lt;!--[if IE 6]&gt;
  &lt;script type='text/javascript'&gt;
    // add ie6 specific print.css
  &lt;/script&gt;
&lt;![endif]--&gt;</code></pre>
<p>This violates my aim to keep output as small as possible but footprint has to take second place to bug-free. I could have translated the code to use <a title="JavaScript conditional comments" href="http://en.wikipedia.org/wiki/Conditional_comment#Conditional_Comment_in_JScript">JavaScript conditional comments</a> by translating the IE version to the JavaScript engine it uses but this could lead to future-proofing problems.</p>
<p>To maintain the order of stylesheets, I added each event to an array of functions and then used a single event to loop through the array of functions. If jQuery is used, I add multiple events because jQuery runs events on a first in first out basis.</p>
<p>Putting the PHP in a class and the JavaScript in its own namespace is fairly self-explanatory. <a href="http://bit.ly/bBUXCh">Google is your friend</a> if you wish to read up further on this.</p>
<p>Minimising the footprint was also a simple step. I wrote the JavaScript out in full with friendly variable names. Once I was happy with the code, I ran the code through <a href="http://refresh-sf.com/yui/">the YUI JavaScript compressor</a>, commented out the original JavaScript in the plugin file and output the compressed version in its place.</p>
<p>The JavaScript is output inline (within the HTML) to avoid additional HTTP requests. I was in two minds about this because browser caching is lost in the process. So it may change in a later version.</p>
<p>I&#8217;ve worked out another way to keep the footprint small. Rather than creating a function to pass the stylesheet&#8217;s URL and ID to <code>brt_print.add(url, id)</code>, I wrote out the full function for each style sheet. I&#8217;ll fix that in the next release.</p>
<p>You can <a title="download" href="http://wordpress.org/extend/plugins/delay-print-css/download/">download</a> the <a title="Delay Print CSS Plugin" href="http://http://wordpress.org/extend/plugins/delay-print-css/">Delay Print CSS Plugin</a> from the WordPress plugin repository.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/delay-print-css-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Delay loading of print CSS</title>
		<link>http://bigredtin.com/behind-the-websites/delay-loading-of-print-css/</link>
		<comments>http://bigredtin.com/behind-the-websites/delay-loading-of-print-css/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 05:03:50 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://bigredtin.pressgiant.net/?p=689</guid>
		<description><![CDATA[Recently I stumbled across an article detailing browser performance with the CSS print media type. In most recent browsers the print stylesheet held up rendering.

The article suggested a solution, which I decided to automate for WordPress.]]></description>
			<content:encoded><![CDATA[<p>Recently I stumbled across an article on zOompf <a title="detailing browser performance with the CSS print media type" href="http://zoompf.com/blog/2009/12/browser-performance-problem-with-css-print-media-type">detailing browser performance with the CSS print media type</a>. In most recent browsers, Safari being the exception, the print stylesheet held up rendering of the page.</p>
<p>The zOomph article suggests a solution, to load print stylesheets using JavaScript once the page has  rendered (ie, on the <code>window.onload</code> event), with a backup for the JavaScript impaired. You can see their code in the original article.</p>
<h4>Automating the task for WordPress</h4>
<p>Most sites I develop are in WordPress so I decided to automate the process. This relies on using <code>wp_enqueue_style</code> to register the stylesheets:</p>
<pre><code>function enqueue_css(){
  if (!is_admin()){
    wp_enqueue_style (
      'bigred-print', /* handle */
      '/path-to/print.css', /* source */
      null, /* no requirements */
      '1.0', /* version */
      'print' /* media type */
    );
  }
}
add_action('wp_print_styles', 'enqueue_css');</code></pre>
<p>The above code will output the following HTML in the header:</p>
<pre><code>&lt;link rel='stylesheet' id='bigred-print-css'  href='/path-to/print.css?ver=1.0' type='text/css' media='print' /&gt;</code></pre>
<p>The first step is to wrap the above html in noscript tags, the WordPress <a title="filter" href="http://codex.wordpress.org/Plugin_API#Filters">filter</a> <code>style_loader_tag</code> is ideal for this.</p>
<pre><code>function js_printcss($tag, $handle) {
  global $wp_styles;
  if ($wp_styles-&gt;registered[$handle]-&gt;args == 'print') {
    $tag = "&lt;noscript&gt;" . $tag . "&lt;/noscript&gt;";
  }
  return $tag;
}
add_filter('style_loader_tag', 'js_printcss', 5, 2);</code></pre>
<p>The filter runs for all stylesheets, regardless of media type, so the function checks for print stylesheets and wraps them in the <code>noscript</code> tag, other media types are left alone.</p>
<p>The first two arguments are the filter and function names respectively, the third argument specifies the timing (5 is the default) and the final argument tells WordPress how many arguments to pass to the filter – two – in this case $tag and $handle.</p>
<p>With the new filter, WordPress now outputs following HTML in the header:</p>
<pre><code>&lt;noscript&gt;
&lt;link rel='stylesheet' id='bigred-print-css'  href='/path-to/print.css?ver=1' type='text/css' media='print' /&gt;
&lt;/noscript&gt;</code></pre>
<p>The next step is to add the JavaScript to load the stylesheets, we can do this by changing our original function,  <code>js_printcss</code>, and making use of a global variable:</p>
<pre><code>$printCSS = '';

function js_printcss($tag, $handle){
  global $wp_styles, $printCSS;
  if ($wp_styles-&gt;registered[$handle]-&gt;args == 'print') {

    $tag = "&lt;noscript&gt;" . $tag . "&lt;/noscript&gt;";

    preg_match("/&lt;\s*link\s+[^&gt;]*href\s*=\s*[\"']?([^\"' &gt;]+)[\"' &gt;]/", $tag, $hrefArray);
    $href = $hrefArray[1];

    $printCSS .= "var cssNode = document.createElement('link');";
    $printCSS .= "cssNode.type = 'text/css';";
    $printCSS .= "cssNode.rel = 'stylesheet';";
    $printCSS .= "cssNode.href = '" . esc_js($href) . "';";
    $printCSS .= "cssNode.media = 'print';";
    $printCSS .= "document.getElementsByTagName(\"head\")[0].appendChild(cssNode);";
  }
  return $tag;
}</code></pre>
<p>The code creates the PHP variable <code>$printCSS</code> globally, which is then called into the function using the global command.</p>
<p>After wrapping the tag in the <code>noscript</code> tags, the new function uses a regular expression to extract the URL of the stylesheet from the link tag and placing it the variable <code>$href</code>.</p>
<p>Having extracted the stylesheet&#8217;s URL, the function then appends the required JavaScript to the PHP global variable <code>$printCSS</code>.</p>
<p>The final step is to add the JavaScript to the footer of the HTML using the wp_footer action in WordPress. The PHP to do this is:</p>
<pre><code>function printCSS_scriptTags(){
  global $printCSS;
  if ($printCSS != '') {
    echo "&lt;script type='text/javascript'&gt;\n";
    echo "window.onload = function(){\n";
    echo $printCSS;
    echo "}\n&lt;/script&gt;";
  }
}

add_action('wp_footer', 'printCSS_scriptTags');</code></pre>
<p>The above code uses <code>window.onload</code> as dictated in the original article. A better method would be to use an event listener to do the work, for those using jQuery we would change the function to:</p>
<pre><code>function printCSS_scriptTags(){
  global $printCSS;
  if ($printCSS != '') {
    echo "&lt;script type='text/javascript'&gt;\n";
    echo "jQuery(window).ready(function(){\n";
    echo $printCSS;
    echo "});\n&lt;/script&gt;";
 }

}
add_action('wp_footer', 'printCSS_scriptTags');</code></pre>
<p>The above solution had been tested for very limited circumstances only and found to have worked. Were I to use the function in a production environment I would undertake further testing.</p>
<p>Another question to ask is whether all this is actually worth the effort – even when reduced through automation. On Big Red Tin, the print.css is 595 bytes, the delay in rendering is negligible.</p>
<p><strong>Update Aug 23, 2010</strong>: Fixed a type in the code block redefining <code>js_printcss</code>.</p>
<p><strong>Update Aug 27, 2010</strong>: I&#8217;ve decided to release this as a plugin, get the skinny and the plugin from the <a href="http://bigredtin.com/behind-the-websites/delay-print-css-plugin/">followup article</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/delay-loading-of-print-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript the WordPress Way / Part 2</title>
		<link>http://bigredtin.com/behind-the-websites/javascript-the-wordpress-way-part-2/</link>
		<comments>http://bigredtin.com/behind-the-websites/javascript-the-wordpress-way-part-2/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 00:00:20 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[theme]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wp_enqueue_script]]></category>
		<category><![CDATA[wp_enqueue_style]]></category>
		<category><![CDATA[wp_register_script]]></category>
		<category><![CDATA[wp_register_style]]></category>

		<guid isPermaLink="false">http://bigredtin.pressgiant.net/?p=499</guid>
		<description><![CDATA[In Part 1 we introduced the <code>wp_register_script</code> and <code>wp_enqueue_script</code> functions developed to avoid JavaScript conflicts.

In this section we’ll deal with a more complicated example. We’ll also take what we’ve learnt about including JavaScript and apply it to our CSS.]]></description>
			<content:encoded><![CDATA[<p>In <a title="Part 1" href="http://bigredtin.com/behind-the-websites/javascript-the-wordpress-way-part-1/">Part 1</a> we discussed the conflicts that can occur on a WordPress site if themes and plugins add JavaScript using &lt;script&gt; tags. We introduced the <code>wp_register_script</code> and <code>wp_enqueue_script</code> functions developed to avoid these conflicts.</p>
<p>In this section we&#8217;ll deal with a <a title="more complicated example" href="#jswp2complicated">more complicated example</a> and <a title="use Google's AJAX libraries API" href="#jswp2googleapi">use Google&#8217;s AJAX libraries API</a> to lower your bandwidth costs. We&#8217;ll also take what we&#8217;ve learnt about including JavaScript and <a title="apply it to our CSS" href="#jswpcss">apply it to our CSS</a>.<span id="more-499"></span></p>
<h4 id="jswp2complicated">A more complicated example</h4>
<p>The <a title="sample code yesterday" href="http://bigredtin.com/behind-the-websites/javascript-the-wordpress-way-part-1/#jswpregister">sample code yesterday</a> included a simple example of using the same JavaScript file throughout your site. Let&#8217;s spice things up slightly by introducing the following circumstance. Consider that you have three JavaScript files:</p>
<ul>
<li><strong>base.js</strong> is the base JavaScript file to be used throughout the site. It uses the jQuery library and must load in the HTML &lt;head&gt;;</li>
<li><strong>posts.js</strong> loads on pages and posts and only calls functions from the base JavaScript file but doesn&#8217;t use the jQuery library directly. It can load in the HTML footer.</li>
<li><strong>archives.js</strong> loads on all other pages throughout your site (except admin). It calls functions from your base JavaScript file and makes direct use of the jQuery library. It can load in the HTML footer.</li>
</ul>
<p>In this situation, you could change your base.js to use another library – say, Prototype – and it would have no effect on the posts.js. So, posts.js can be said not to depend on jQuery directly.</p>
<p>Changing libraries would require edits to the third file, in which case archives.js does depend on jQuery directly.</p>
<h5>Registering the Files</h5>
<p>The code to register those JavaScript files and conditions with WordPress is:</p>
<pre><code>wp_register_script (
  'mytheme-base', /* handle */
  get_bloginfo('template_url') . '/base.js', /* source */
  array('jquery'), /* requires jQuery */
  1.0 /* version 1.0 */
);

wp_register_script (
  'mytheme-posts', /* handle */
  get_bloginfo('template_url') . '/posts.js', /* source */
  array('mytheme-base'), /* requires base.js */
  1.0, /* version 1.0 */
  true /* load in footer */
);

wp_register_script (
  'mytheme-archives', /* handle */
  get_bloginfo('template_url') . '/archives.js', /* source */
  array('jquery', 'mytheme-base'), /* requires jQuery &amp; base.js */
  1.0, /* version 1.0 */
  true /* load in footer */
);</code></pre>
<p>This code says to WordPress:</p>
<ul>
<li> If loading posts.js, also load base.js;</li>
<li> If loading archives.js, also load jQuery and base.js;</li>
<li> If loading base.js, also load jQuery;</li>
</ul>
<p>Each of these are separate checks (if) rather than a series of options (if, else if).</p>
<h5>Enqueueing the files</h5>
<p>All the hard work has been done registering the files, WordPress knows what each file requires to work and where in the HTML (&lt;head&gt; or footer) the &lt;script&gt; tags should be inserted.</p>
<p>Now it&#8217;s a simple process of checking if the visitor is loading a post or page and requesting the appropriate file.</p>
<p>We need to delay the check slightly, otherwise WordPress won&#8217;t know if the user is on a page, post or elsewhere. The first step is to enclose the check in a function.</p>
<pre><code>function que_scripts(){
  if (!is_admin()) { //visitors only
    if (is_singular()) { // pages &amp; posts
      wp_enqueue_script('mytheme-posts');
    }
    else {
      wp_enqueue_script('mytheme-archives');
    }
  }
}</code></pre>
<p>Then tell WordPress when to execute the function. For this we use the <a title="action" href="http://codex.wordpress.org/Plugin_API#Hooks.2C_Actions_and_Filters">action</a> wp_print_scripts. This runs the code above before WordPress attempts to output the <code>&lt;script&gt;</code> tags to your HTML.</p>
<pre><code>add_action('wp_print_scripts', 'que_scripts')</code></pre>
<p>There is no need to enqueue jQuery or base.js directly. WordPress knows to add those to the HTML based on the dependancies listed when registering the files.</p>
<h4 id="jswp2googleapi">Using the Google AJAX Libraries API</h4>
<p>Loading all these libraries from your own server may seem like a waste of your bandwidth considering you could be loading the libraries directly from Google&#8217;s servers.</p>
<p>With a bit of luck, your visitor will have Google&#8217;s version of the libraries in their browser&#8217;s cache already and <a title="your site will load a little quicker" href="http://bigredtin.com/behind-the-scenes/caching-on-the-google-ajax-libraries-api/">your site will load a little quicker</a>.</p>
<p>It&#8217;s a bit messy to do this yourself, especially since jQuery needs to be kept in noConflict mode. Fortunately <a title="Jason Penny" href="http://jasonpenney.net/">Jason Penny</a> has developed a plugin, called “<a title="Use Google Libraries" href="http://wordpress.org/extend/plugins/use-google-libraries/">Use Google Libraries</a>”, to do the hard work for you.</p>
<p>“Use Google Libraries” is the first plugin I add when setting up sites for me and my clients.</p>
<h4 id="jswp2superfab">Making our super-broken example super-fabulous</h4>
<p>If, when developing their theme and plugin, George and Richard <a title="from our example in Part 1" href="http://bigredtin.com/behind-the-websites/javascript-the-wordpress-way-part-1/#jswpproblem">from our  example in Part 1</a>, had used the <code>wp_register_script</code> and <code>wp_enqueue_script</code> WordPress functions to load their JavaScript, WordPress would know that only one version of jQuery needs to be loaded for both the theme and the plugin to work.</p>
<p>As WordPress releases come in fits and bursts, sometimes the version of the JS libraries included with WordPress fall behind the current version of the library available otherwise.</p>
<p>This is a small price to pay for the knowledge that our sites will remain super-fabulous rather than super-broken, at least when it comes to the JavaScript.</p>
<h4 id="jswpcss">A bonus for CSS</h4>
<p>By now the reasons for using <code>wp_register_script</code> and <code>wp_enqueue_script</code> should be clear. If you want to go that one step further, you can use the equivalent functions for your CSS.</p>
<p>As CSS should always be loaded in the HTML &lt;head&gt;, there is no option to load the CSS files in the footer of the HTML. Otherwise the CSS functions take the same arguments as their JavaScript equivalents. The CSS functions are:</p>
<ul>
<li>wp_register_style</li>
<li>wp_enqueue_style</li>
</ul>
<p>The four parameters they take are:</p>
<dl>
<dt>$handle</dt>
<dd>(required for both functions) Name of the style sheet</dd>
<dt>$source</dt>
<dd>(required for <code>wp_register_style</code>) – URL of the script. Also required by <code>wp_enqueue_style</code> if the style is unregistered.</dd>
<dt>$dependancies</dt>
<dd>(optional) – an array of handles the style sheet depends on</dd>
<dt>$version</dt>
<dd>(optional) – version number</dd>
</dl>
<p>WordPress doesn&#8217;t include any style sheets bases, such as YUI CSS, in the default distribution, so the main purpose of the CSS functions is to allow you to keep track of your version numbers and to call in style sheets only as they&#8217;re needed.</p>
<h4>Conditional comments</h4>
<p>Unfortunately the WordPress functions for JavaScript do not allow for conditional comments, so scripts targeting older versions of IE (okay, I&#8217;m referring to PNG fixers for IE6) need to be coded directly into your theme&#8217;s header.php or footer.php.</p>
<p>On the other hand, the CSS functions do allow for conditional comments, in a round-about fashion. Let&#8217;s register a CSS file we&#8217;ll be targeting at IE6.</p>
<pre><code>wp_register_style (
  'mytheme-ie6', /* handle */
  get_bloginfo('template_url') . '/ie6.css', /* source */
  array('mytheme-css'), /* requires mytheme-css (not shown) */
  1.0 /* version 1.0 */
);</code></pre>
<p>Behind the scenes WordPress is adding the stylesheet to the object $wp_styles. To add the conditional comments you need to access the object more directly. To target the above to IE6, the command is:</p>
<pre><code>$wp_styles-&gt;registered['mytheme-ie6']-&gt;extra['conditional'] = 'IE 6';</code></pre>
<p>If, as in the complicated example above, you need to check where a user is before enqueueing your stylesheet, again you need to enclose the enqueueing command in a function and run it on an action, in this case the action <code>wp_print_styles</code>.</p>
<p>For example, to output the IE6 stylesheet above on pages and posts only, the full code would be:</p>
<pre><code>function que_styles(){
  if (!is_admin()) { //visitors only
    if (is_singluar() {
      wp_enqueue_style('mytheme-ie6');
    }
  }
}

add_action('wp_print_styles', 'que_styles')</code></pre>
<h4>Conclusion</h4>
<p>The methods described in this tutorial may appear to complicate matters for little pay off, especially if you&#8217;re developing a theme or plugin for your own site.</p>
<p>Replacing your &lt;script&gt; tags with the code above, it is true, will have almost no effect on the HTML or JavaScript output by WordPress. What&#8217;s worse, if you use the $ alias for jQuery in your JavaScript, you&#8217;ll need to edit both the theme&#8217;s php and JavaScript files.</p>
<p>These functions, <code>wp_register_script</code> and <code>wp_enqueue_script</code>, aren&#8217;t about now, however, they&#8217;re about “then”.</p>
<ul>
<li>Then&#8230; I activated this plugin and my JavaScript stopped working.</li>
<li>Then&#8230; I changed the theme and my favourite plugin stopped working</li>
<li>Then&#8230; I looked at the source code, and two copies of jQuery were being sent to every visitor</li>
</ul>
<p>The WordPress developers have seen the problems JavaScript conflicts can cause, and developed these functions to make your theme or plugin more robust. It&#8217;s the added robustness, for such little effort, that make these functions worth using.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/javascript-the-wordpress-way-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rounded Corners Everywhere</title>
		<link>http://bigredtin.com/behind-the-websites/rounded-corners-everywhere/</link>
		<comments>http://bigredtin.com/behind-the-websites/rounded-corners-everywhere/#comments</comments>
		<pubDate>Wed, 26 May 2010 02:34:42 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[border-radius]]></category>
		<category><![CDATA[browser support]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[rgba]]></category>
		<category><![CDATA[rounded corners]]></category>

		<guid isPermaLink="false">http://bigredtin.pressgiant.net/?p=431</guid>
		<description><![CDATA[Similar support of <a title="rgba" href="http://24ways.org/2009/working-with-rgba-colour">rgba</a> and <a title="border-radius" href="http://www.zenelements.com/blog/css3-border-radius-rounded-corners/">border-radius</a> in modern browsers allows us to use both the old graphical and new css3 methods for rounded corners. This gives us the same look in almost all browsers.]]></description>
			<content:encoded><![CDATA[<p>Spending some time looking at CSS3 support on <a title="Can I Use dot com" href="http://caniuse.com">caniuse.com</a>, I noticed how similar browser support for <a title="border-radius" href="http://www.zenelements.com/blog/css3-border-radius-rounded-corners/">border-radius</a> and <a title="rgba colours" href="http://24ways.org/2009/working-with-rgba-colour">rgba colours</a> is:</p>
<p><img class="alignnone size-large wp-image-432" title="RGBA support Vs border-radius support" src="http://bigredtin.com/files/2010/05/rgba-vs-border-radius-635x488.jpg" alt="RGBA support Vs border-radius support" width="635" height="488" /><br />
– <a title="source" href="http://caniuse.com/#agents=All&amp;eras=All&amp;cats=CSS3&amp;statuses=rec,pr,cr,wd,ietf">source</a><br />
The striking similarity allows us to use both the old graphical and new css3 methods for rounded corners, giving us the same look in almost all browsers but without wasting the bandwidth of users with modern browsers.</p>
<p>At Big Red Tin, we&#8217;ve used this method for the top corners of the twitter bubble on the left, the relevant CSS is:</p>
<pre><code>.aktt_widget .aktt_tweets {
  background: #999
              url(10pxrounded-210w-24.png)
              no-repeat top center;

  background: rgba(153,153,153,1) none;

     -moz-border-radius: 10px; /* FF1+ */
  -webkit-border-radius: 10px; /* Saf3+, Chrome */
          border-radius: 10px; /* Opera 10.5, IE 9 */
}</code></pre>
<p>– <a title="source" href="http://css.assets.sgiant.com/pressgiant/wp-content/themes/bigredtin/assets/child/c/screen/screen.css">source</a> (search for .aktt_widget .aktt_tweets)</p>
<p>Browsers that don&#8217;t support rgba colours use the first background call which includes an image to emulate rounded corners. Browsers that do support rgba use the second background call, which includes a fully opaque colour but no background image, for the most part these browser can interpret the border-radius calls that follow.</p>
<p>This method falls over in Opera 10.1, which displays a square border, and will fall over in IE9, which will interpret the border-radius call <em>and</em> download the image. I don&#8217;t see these couple of exceptions as a big problem, as browser support always involves catering to the majority.</p>
<p>Do you exploit a similar coincidence of browser support? <a title="Share it in the comments" href="http://bigredtin.com/behind-the-websites/rounded-corners-everywhere/#comments">Share it in the comments</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/rounded-corners-everywhere/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Charging for themes? Do the right thing!</title>
		<link>http://bigredtin.com/behind-the-websites/charging-for-themes-do-the-right-thing/</link>
		<comments>http://bigredtin.com/behind-the-websites/charging-for-themes-do-the-right-thing/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 00:23:42 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[themes]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://soupgiant.com/?p=240</guid>
		<description><![CDATA[Of all the Wordpress functions, I think wp_register_script, wp_register_style, wp_enqueue_script, and, wp_enqueue_style are the most elegant.]]></description>
			<content:encoded><![CDATA[<p>Of all the WordPress functions, I think <code>wp_register_script</code>, <code>wp_register_style</code>, <code>wp_enqueue_script</code>, and, <code>wp_enqueue_style</code> are the most elegant. It&#8217;s possible to get away with using only the <code>wp_enqueue_*</code> functions, but I prefer to use both for a little bit more control.</p>
<p>For the uninitiated, these functions allow you to add JavaScript and CSS files to the header (or footer, in later versions of <abbr title="WordPress">WP</abbr>) without running of the risk of another plugin adding the same file, that is, you avoid the following:</p>
<pre><code>&lt;script type="text/javascript" source="http://.../a-plugin/jQuery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" source="http://.../a-plugin/plugin.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" source="http://.../my-theme/jQuery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" source="http://.../my-theme/theme.js"&gt;&lt;/script&gt;</code></pre>
<p>If you develop themes or plugins for WordPress and are unaware of these functions, you should refer to the codex to get the low down on at least <code><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script">wp_enqueue_script</a></code>, and <code><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style">wp_enqueue_style</a></code> &#8211; these register and queue the files, the <code>wp_register_*</code> functions register the file ready to be queued for output.</p>
<h4>The Rant</h4>
<p>Despite the value these functions can add to themes and plugins, they are under-utilised in development. The functions have wider adoption in plug-in development, but it&#8217;s still well below 100%. In theme development adoption is virtually non-existent (at least in the themes I&#8217;ve used).</p>
<p>This failure to code properly is evenly spread across both free and paid themes. I?m happy to look the other way for free themes. After all, the motivation behind the theme may have been to learn WordPress development.</p>
<p>In commercial themes, particularly those above the US$30-$35 price point, it&#8217;s downright frustrating that these products haven&#8217;t been developed properly.</p>
<p>When someone purchases a theme, they shouldn&#8217;t have to debug the product to find out why a JavaScript framework is being included twice. The reason for the purchase is that they either don&#8217;t want to, or know how to, develop.</p>
<h4>Avoiding costly mistakes</h4>
<p>Evaluating a commercial theme on behalf of a client triggered this rant. At $195, it&#8217;s quite expensive in the world of WordPress. As I was viewing the source code of the online demo, I discovered the <em>faux pas</em>. We&#8217;ll advise against using that theme as a starting point. In fact, within short time we&#8217;d found a theme $195 cheaper that would do the job.</p>
<p>Looking at the source code of a demo site is usually enough to tell you how the theme is inserting its scripts:</p>
<ul>
<li>Both &lt;link&gt; and &lt;script&gt; tags will use single quotes around attributes (&#8216;), rather than double quotes (&#8220;),</li>
<li>CSS &lt;link&gt; tags will have an ID attribute ending in -css, eg: id=&#8217;shadowbox-css-css&#8217;, and,</li>
<li>JavaScript and CSS files include the version number as a query string eg jQuery.js?ver=1.3.2 (although a hook can be used to remove this)</li>
</ul>
<p>Making sure that the <code>wp_register_script</code>, <code>wp_register_style</code>, <code>wp_enqueue_script</code>, and, <code>wp_enqueue_style</code> are included properly will save time, bandwidth and also avoid some detrimental conflicts.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/charging-for-themes-do-the-right-thing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why I will not be dropping support for IE6</title>
		<link>http://bigredtin.com/behind-the-websites/not-dropping-ie6/</link>
		<comments>http://bigredtin.com/behind-the-websites/not-dropping-ie6/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 01:30:58 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[doctype]]></category>
		<category><![CDATA[ie6]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[quirks mode]]></category>
		<category><![CDATA[standards mode]]></category>
		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://peterwilson.cc/?p=97</guid>
		<description><![CDATA[Increasingly I'm reading of web developers deciding to drop IE6 from their list of supported browsers, usually, because of its creative interpretation of CSS standards, besides IE7 is over a year old, and, IE8 about to be released.]]></description>
			<content:encoded><![CDATA[<p>Increasingly I&#8217;m reading of web developers deciding to drop <abbr title="Internet Explorer 6">IE6</abbr> from their list of supported browsers, usually, because of its <em>creative</em> interpretation of CSS standards, besides <abbr title="Internet Explorer 7">IE7</abbr> is over a year old, and, <abbr title="Internet Explorer 8">IE8</abbr> about to be released.</p>
<p>I&#8217;ve decided to continue support for <abbr title="Internet Explorer 6">IE6</abbr> as it&#8217;s still in wide use &#8211; especially in corporate environments &#8211; and, I don&#8217;t think it needs to take a lot of work to develop for. I&#8217;ll say that again, I don&#8217;t think <abbr title="Internet Explorer 6">IE6</abbr> is as bad it&#8217;s sometimes made out to be.</p>
<p><span id="more-97"></span><abbr title="Internet Explorer 6">IE6</abbr> is the difficult child of the browser family &#8211; but like most difficult children, with the right tools it can be made to behave. <abbr title="Internet Explorer 7">IE7</abbr> is better behaved than <abbr title="Internet Explorer 6">IE6</abbr>, but let&#8217;s not fool ourselves, it&#8217;s not the glowing example of a perfect browser, and requires hacks of its own.</p>
<h4>Standards Mode</h4>
<p>The best tool to reduce <abbr title="Internet Explorer 6">IE6</abbr>&#8216;s development time is to move the browser out of <a title="Quirks Mode" href="http://en.wikipedia.org/wiki/Quirks_mode">quirks mode</a> and into standards mode using an appropriate DOCTYPE, and, leaving off the XML declaration; I code in XHTML Strict, so my files begin:</p>
<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;</code></pre>
<p>In standards mode the browser will inherit font styles within tables, use the W3C box model and vertical alignment defaults.</p>
<h4>Comments</h4>
<p>Create a standard comment format for your main CSS file which you can use when you know you&#8217;re going to have to write a hack for the <abbr title="Internet Explorer 6">IE6</abbr> style sheet, such as <code>/*HACK ie6 ... */;</code> rather than flicking between your main and <abbr title="Internet Explorer 6">IE6</abbr> style sheets during standards development, you can just search for hack comments during non-standards development.</p>
<pre><code>#someDiv {
min-height: 300px; /* HACK ie6 - height: 300px */
float: left; /* HACK ie6 - 3px jog (adjacent), zoom: 1 */
}</code></pre>
<h4>Surprises</h4>
<p>Once you&#8217;ve specified the DOCTYPE, and, repaired known hacks, <abbr title="Internet Explorer 6">IE6</abbr> is likely to surprise you with a few more creative problems, positioning, an extra few pixels here and there and other little tricks; but by ruling out the obvious in advanced, overall debugging will become less time consuming.</p>
<p>As I said above, <abbr title="Internet Explorer 7">IE7</abbr> requires its own set of hacks. If browser specific debugging is required anyway, I don&#8217;t think it&#8217;s overly time consuming to continue support for <abbr title="Internet Explorer 6">IE6</abbr>.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/not-dropping-ie6/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>JavaScript Equal Height Columns</title>
		<link>http://bigredtin.com/behind-the-websites/js-equal-height-cols/</link>
		<comments>http://bigredtin.com/behind-the-websites/js-equal-height-cols/#comments</comments>
		<pubDate>Wed, 24 Dec 2008 02:32:16 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[layout]]></category>

		<guid isPermaLink="false">http://peterwilson.cc/?p=94</guid>
		<description><![CDATA[The desire for equal height columns in a CSS layout is nothing new; there are many solutions available, some use JavaScript, others use CSS with negative margins, and then, there's the faux columns method using background images. All of these methods have their place as perfectly valid solutions, and, depending on the situation, may be the best solution available.]]></description>
			<content:encoded><![CDATA[<p>The desire for equal height columns in a CSS layout is nothing new; there are many solutions available, some use JavaScript, others use <a title="One True Layout" href="http://www.positioniseverything.net/articles/onetruelayout/equalheight">CSS with negative margins</a>, and then, there&#8217;s the <a title="Faux Columns" href="http://www.alistapart.com/articles/fauxcolumns/">faux columns</a> method using background images. All of these methods have their place as perfectly valid solutions, and, depending on the situation, may be the best solution available.  <span id="more-94"></span>It&#8217;s the JavaScript methods available that are the subject this article; most of the solutions available &#8211; certainly those on the first page when <a title="Google 'equal height javascript'" href="http://www.google.com.au/search?q=equal+height+javascript">googling &#8216;equal height javascript&#8217;</a> &#8211; include a variation of either of the lines below:</p>
<pre><code>column[i].style.height = maxHeight + 'px';
// or
column[i].style.minHeight = maxHeight + 'px';</code></pre>
<p>The use of inline styles creates an edge case that can result in a large, ugly, gap between the equalized columns and the footer when printing the page; if footer is pushed on to an otherwise blank page it becomes wasteful.  Example 1: <a title="Layout without equalised columns" href="http://code.peterwilson.cc/js-equal-height-cols/eg1/">Layout without equalised columns</a> Example 2: <a title="Equalised columns with traditional JavaScript" href="http://code.peterwilson.cc/js-equal-height-cols/eg2/">Equalised columns with traditional JavaScript</a> (<a title="Print view of equalised columns with traditional JavaScript" href="http://code.peterwilson.cc/js-equal-height-cols/eg2/print-version.pdf">pdf of print view</a></p>
<p>)</p>
<h4>Basic requirements</h4>
<p>When deciding to write my own version of the script, rather than sending an array, or limiting the script to a certain number of columns, I decided to send the requirements as an expression, ie</p>
<pre><code>PWCC.equalHeights("content=sidebar");</code></pre>
<p>To avoid the printing problem in example 2, CSS is created dynamically and assigned to the relevant media type &#8211; in this case &#8216;screen&#8217; or &#8216;screen, handheld&#8217;. I&#8217;ve used <a title="Using dynamic CSS to hide content before page load" href="http://www.bobbyvandersluis.com/articles/dynamic_css/index.html">a script by Bobby van der Sluis</a> &#8211; modified to allow the specification of the media type and moved it into my namespace &#8211; to create the CSS.</p>
<pre><code>function createStyleRule(selector, declaration) {
//becomes
PWCC.createStyleRule = function (selector, declaration, media) {
if (media == null) {
  media = 'screen';
}

style_node.setAttribute("media", "screen");
//becomes
style_node.setAttribute("media", media);</code></pre>
<h4>The function</h4>
<p>Using the traditional version in example two, the inline styles make it necessary to loop through each column twice, first to get maximum height, and, subsequently to set the height on each element.  In the function below the use of dynamic CSS allows a class name to be created at the start of the script and applied to each column in the initial loop &#8211; very slightly reducing processing power; in the script below a random number is appended to the class name to help ensure there are no clashes with the static CSS &#8211; with a bit of care it can be removed.</p>
<pre><code>PWCC.equalHeight = function (expr, className, media) {
  if (className == null) {
    className = 'equalHeight';
  }
  if (media == null) {
    media = 'screen'; //default
  }

  //split expr at = signs
  var sections = expr.split("=");

  //generate class name
  var classRandom = Math.floor(Math.random()*999999);
  className = className + '-' + classRandom;

  //get column heights, add class name to html elemenets
  var objects = new Array();
  var maxHeight = 0;
  for(var i=0; i &lt; sections.length; i++) {
    objects[i] = document.getElementById(sections[i]);
    PWCC.addClass(objects[i], className);
    //addClass is in base.js - it adds a class to an element.

    if (objects[i].offsetHeight &gt; maxHeight) {
      maxHeight = objects[i].offsetHeight;
    }
  }

  //create css declaration
  var classDeclaration = 'min-height: ' + maxHeight + 'px;'
  var ie6Declaration = 'height: ' + maxHeight + 'px;'
  PWCC.createStyleRule('.' + className, classDeclaration, media);
  PWCC.createStyleRule('* html .' + className, ie6Declaration, media);
}</code></pre>
<p>The IE6 declaration has been made using a * html hack; I considered this a better option than the others available, browser sniffing, or, JavaScript conditional comments; others&#8217; opinions may differ and prefer to avoid the * html hack.  Finally to call the script once the page loads, add a function call to the load event</p>
<pre><code>PWCC.addLoadEvent(function() {
  //addLoadEvent is in base.js - adds code to window.onload
  PWCC.equalHeight('content=sidebar');
});</code></pre>
<p>The <a title="Final version of equal height columns" href="http://code.peterwilson.cc/js-equal-height-cols/eg3/">final working version can be seen in example 3</a>, along with the <a title="Source javascript for example 3" href="http://code.peterwilson.cc/js-equal-height-cols/eg3/assets/j/custom.js.txt">source JavaScript</a>; the function above makes calls to my <a title="Base JavaScript File" href="http://bigredtin.com/index.php?p=82">base.js</a> file.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/js-equal-height-cols/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Review &#8211; Everything you know about CSS is wrong!</title>
		<link>http://bigredtin.com/behind-the-websites/review-everything-you-know-about-css-is-wrong/</link>
		<comments>http://bigredtin.com/behind-the-websites/review-everything-you-know-about-css-is-wrong/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 05:06:15 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[review]]></category>
		<category><![CDATA[sitepoint]]></category>

		<guid isPermaLink="false">http://peterwilson.cc/?p=57</guid>
		<description><![CDATA[During the week I read Rachel Andrew and Kevin Yank's Everything You Know About CSS Is Wrong! At a little over 100 pages it's a concise explanation of CSS tables and how they will - and an argument why they should - change the way in which web developers work.]]></description>
			<content:encoded><![CDATA[<p>During the week I read Rachel Andrew and Kevin Yank&#8217;s <a title="Everything You Know About CSS is Wrong!" href="http://www.sitepoint.com/books/csswrong1/"><em>Everything You Know About CSS Is Wrong!</em></a> At a little over 100 pages it&#8217;s a concise explanation of CSS tables and how they will &#8211; and an argument why they should &#8211; change the way in which web developers work.</p>
<p><em><abbr title="Everything You Know About CSS is Wrong!">EYKACIW!</abbr></em> begins by explaining how today&#8217;s web developer has hacked CSS to do things it was never designed to do, in much the same way that we hacked HTML tables in the heady days of the 1990s; floats, faux columns, negative margins, positioning, and, several more tricks now used as a second nature all get dishonourable mentions.</p>
<p><span id="more-57"></span></p>
<h4>I&#8217;m not so sure</h4>
<p><em><abbr title="Everything You Know About CSS is Wrong!">EYKACIW!</abbr></em> points out that there is no CSS table equivalent of the col- and rowspan attributes in an HTML table, a method is detailed in the book to emulate these features with absolute positioning (also <a title="Rowspans and Colspans in CSS Tables" href="http://www.sitepoint.com/blogs/2008/09/09/rowspans-colspans-in-css-tables/">available on Kevin Yank&#8217;s Sitepoint blog</a>). The method detailed brings to mind the very hacks we&#8217;re being discouraged from using.</p>
<p>Another problem I can foresee is that CSS tables will increase, rather than decrease, the amount div bloat required for a typical layout; replacing <code>&lt;table&gt;&lt;tr&gt;&lt;td&gt;</code> in an old fashioned HTML table layout with <code>&lt;div&gt;&lt;div&gt;&lt;div&gt;</code> &#8211; these otherwise redundant divs aren&#8217;t necessary for a basic layout, but seem to be inevitable for layouts requiring nested tables.</p>
<h4>Hold your horses (and other clich&#8217;s)</h4>
<p>These are my initial reactions to reading about CSS tables, in some ways it reminds me of my reaction &#8211; when learning CSS &#8211; to reading that the width of an element doesn&#8217;t include the padding or the border; my reaction back then was &#8216;but that&#8217;s stupid&#8217;, now it&#8217;s just second nature and the concept of including the padding and border is foreign.</p>
<p><em><abbr title="Everything You Know About CSS is Wrong!">EYKACIW!</abbr></em> is about CSS tables, with an introduction to other CSS3 layout modules in the final chapter, modules that aren&#8217;t implemented in any browser &#8211; such as the grid positioning module and the template layout module &#8211; these modules excite me, CSS tables seem to require a different set of hacks, and &#8211; to paraphrase Regurgitator &#8211; I like your old hacks better than your new hacks.</p>
<p>It&#8217;s possible that the problem with <em>Everything You Know About CSS Is Wrong!</em> is that it was released too early; maybe it would have been better timed for a couple of years down the track when these new modules are in our browsers; regardless the book will cause a lot of discussion within the developer community about the direction in which CSS3 should go, and that&#8217;s only a good thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/review-everything-you-know-about-css-is-wrong/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t start with a reset.css</title>
		<link>http://bigredtin.com/behind-the-websites/dont-start-with-a-resetcss/</link>
		<comments>http://bigredtin.com/behind-the-websites/dont-start-with-a-resetcss/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 02:28:34 +0000</pubDate>
		<dc:creator>Peter Wilson</dc:creator>
				<category><![CDATA[Behind the Websites]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[reset]]></category>

		<guid isPermaLink="false">http://peterwilson.cc/?p=51</guid>
		<description><![CDATA[Earlier this year, Jonathan Snook wrote an article on why he doesn't use a reset.css in which he referred to Eric Meyer's reset, a short time later, Eric Meyer responded with an article of his own. Unlike many discussions on the web, it wasn't a mudslinging match, but a sincere discussion of the tools available to web developers.]]></description>
			<content:encoded><![CDATA[<p>Earlier this year, Jonathan Snook wrote an article on <a title="No CSS Reset" href="http://snook.ca/archives/html_and_css/no_css_reset/">why he doesn&#8217;t use a reset.css</a> in which he referred to Eric Meyer&#8217;s reset, a short time later, <a title="Crafting Ourselves" href="http://meyerweb.com/eric/thoughts/2008/04/17/crafting-ourselves/">Eric Meyer responded</a> with an article of his own. Unlike many discussions on the web, it wasn&#8217;t a mudslinging match, but a sincere discussion of the tools available to web developers.</p>
<p>My initial thoughts were that a reset style sheet, combined with a base style sheet, was a <em>helpful</em> place to start any web project as it reduces the incidence of unexpected results. I thought it was important for the developer to have her own reset and base styles; blindly adopting someone else&#8217;s reset and base style sheets will just lead to a different set of surprises.</p>
<p><span id="more-53"></span>While these discussions were going on, I was in the process of developing my own base style sheets, running them against <a title="YUI XHTML Test" href="http://developer.yahoo.com/yui/examples/base/base-simple_source.html">YUI&#8217;s XHTML test suite</a>; shortly afterwards I began to regret the decisions I&#8217;d made.</p>
<p>I concluded that the best place to start was with my own <a title="Peter Wilson Base XHTML document" href="http://code.peterwilson.cc/dont-start-with-a-reset-css/">base XHTML document</a>, something I can start a project with and remove anything that&#8217;s not needed for the particular project.</p>
<p>Viewing the source of my base XHTML you&#8217;ll see an overly complicated document that will never be used in its entirety on a single project.</p>
<pre><code>&lt;div id="content-body"&gt;
  &lt;div id="content-a"&gt;
  &lt;/div&gt;
  &lt;!-- //#content-a --&gt;

  &lt;div id="content-b"&gt;
  &lt;/div&gt;
  &lt;!-- //#content-b --&gt;
&lt;/div&gt;
&lt;!-- //#content-body --&gt;</code></pre>
<p>In a project with a single column of content, there is no point in dividing the content into content-a and content-b; that&#8217;s a deliberate redundancy, I&#8217;d much rather highlight a block of code and hit delete than re-write type the code every time I need it. The same process applies for sidebar-a and -b.</p>
<p>None of this is to say that base style sheets are bad, they&#8217;re still very useful tools, just that it is important to begin with something to run your styles against.</p>
]]></content:encoded>
			<wfw:commentRss>http://bigredtin.com/behind-the-websites/dont-start-with-a-resetcss/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
