<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
   <channel>
      <title>CSS-Tricks Snippet Feed</title>
      <description>Pipes Output</description>
      <link>http://pipes.yahoo.com/pipes/pipe.info?_id=ed5d0448a663b3bb5c22cafea4c13d1a</link>
      <atom:link rel="next" href="http://pipes.yahoo.com/pipes/pipe.run?_id=ed5d0448a663b3bb5c22cafea4c13d1a&amp;_render=rss&amp;page=2" />
      <pubDate>Sun, 27 May 2012 00:47:05 +0000</pubDate>
      <generator>http://pipes.yahoo.com/pipes/</generator>
      <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/CSS-TricksSnippets" /><feedburner:info uri="css-trickssnippets" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
         <title>Calendar Function</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/SyLXqCTa3kA/</link>
         <description>&lt;code&gt;&amp;#60;?php

function build_calendar($month,$year,$dateArray) {

    // Create array containing abbreviations of days of week.
    $daysOfWeek = array('S','M','T','W','T','F','S');

    // What is the first day of the month in question?
    $firstDayOfMonth = mktime(0,0,0,$month,1,$year);

    // How many days does this month contain?
    $numberDays = date('t',$firstDayOfMonth);

    // Retrieve some information about the first day of the
    // month in question.
    $dateComponents = getdate($firstDayOfMonth);

    // What is the name of the month in question?
    $monthName = $dateComponents['month'];

    // What is the index value (0-6) of the &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17062</guid>
         <pubDate>Fri, 25 May 2012 01:23:04 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>&lt;?php

function build_calendar($month,$year,$dateArray) {

    // Create array containing abbreviations of days of week.
    $daysOfWeek = array('S','M','T','W','T','F','S');

    // What is the first day of the month in question?
    $firstDayOfMonth = mktime(0,0,0,$month,1,$year);

    // How many days does this month contain?
    $numberDays = date('t',$firstDayOfMonth);

    // Retrieve some information about the first day of the
    // month in question.
    $dateComponents = getdate($firstDayOfMonth);

    // What is the name of the month in question?
    $monthName = $dateComponents['month'];

    // What is the index value (0-6) of the first day of the
    // month in question.
    $dayOfWeek = $dateComponents['wday'];

    // Create the table tag opener and day headers

    $calendar = "&lt;table class='calendar'&gt;";
    $calendar .= "&lt;caption&gt;$monthName $year&lt;/caption&gt;";
    $calendar .= "&lt;tr&gt;";

    // Create the calendar headers

    foreach($daysOfWeek as $day) {
         $calendar .= "&lt;th class='header'&gt;$day&lt;/th&gt;";
    }

    // Create the rest of the calendar

    // Initiate the day counter, starting with the 1st.

    $currentDay = 1;

    $calendar .= "&lt;/tr&gt;&lt;tr&gt;";

    // The variable $dayOfWeek is used to
    // ensure that the calendar
    // display consists of exactly 7 columns.

    if ($dayOfWeek &gt; 0) {
         $calendar .= "&lt;td colspan='$dayOfWeek'&gt;&amp;nbsp;&lt;/td&gt;";
    }

    $month = str_pad($month, 2, "0", STR_PAD_LEFT);

    while ($currentDay &lt;= $numberDays) {

         // Seventh column (Saturday) reached. Start a new row.

         if ($dayOfWeek == 7) {

              $dayOfWeek = 0;
              $calendar .= "&lt;/tr&gt;&lt;tr&gt;";

         }

         $currentDayRel = str_pad($currentDay, 2, "0", STR_PAD_LEFT);

         $date = "$year-$month-$currentDayRel";

         $calendar .= "&lt;td class='day' rel='$date'&gt;$currentDay&lt;/td&gt;";

         // Increment counters

         $currentDay++;
         $dayOfWeek++;

    }

    // Complete the row of the last week in month, if necessary

    if ($dayOfWeek != 7) {

         $remainingDays = 7 - $dayOfWeek;
         $calendar .= "&lt;td colspan='$remainingDays'&gt;&amp;nbsp;&lt;/td&gt;";

    }

    $calendar .= "&lt;/tr&gt;";

    $calendar .= "&lt;/table&gt;";

    return $calendar;

}

?&gt;</code></pre>
<h4>Usage</h4>
<p>To print a table of May 2005, just do:</p>
<pre><code>&lt;?php echo build_calendar(05,2005); ?&gt;</code></pre>
<p>And you'll get a table like this:</p>
<table class="calendar">
<caption>May 2005</caption>
<tbody>
<tr>
<th class="header">S</th>
<th class="header">M</th>
<th class="header">T</th>
<th class="header">W</th>
<th class="header">T</th>
<th class="header">F</th>
<th class="header">S</th>
</tr>
<tr>
<td class="day">1</td>
<td class="day">2</td>
<td class="day">3</td>
<td class="day">4</td>
<td class="day">5</td>
<td class="day">6</td>
<td class="day">7</td>
</tr>
<tr>
<td class="day">8</td>
<td class="day">9</td>
<td class="day">10</td>
<td class="day">11</td>
<td class="day">12</td>
<td class="day">13</td>
<td class="day">14</td>
</tr>
<tr>
<td class="day">15</td>
<td class="day">16</td>
<td class="day">17</td>
<td class="day">18</td>
<td class="day">19</td>
<td class="day">20</td>
<td class="day">21</td>
</tr>
<tr>
<td class="day">22</td>
<td class="day">23</td>
<td class="day">24</td>
<td class="day">25</td>
<td class="day">26</td>
<td class="day">27</td>
<td class="day">28</td>
</tr>
<tr>
<td class="day">29</td>
<td class="day">30</td>
<td class="day">31</td>
<td colspan="4">&nbsp;</td>
</tr>
</tbody>
</table><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/SyLXqCTa3kA" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/calendar-function/</feedburner:origLink></item>
      <item>
         <title>Support Tabs in Textareas</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/gkWvf36Lkw4/</link>
         <description>&lt;p&gt;Normally the tab key moves to the next focusable thing. This inserts a tab character in instead.&lt;/p&gt;
&lt;code&gt;HTMLTextAreaElement.prototype.getCaretPosition = function () { //return the caret position of the textarea
    return this.selectionStart;
};
HTMLTextAreaElement.prototype.setCaretPosition = function (position) { //change the caret position of the textarea
    this.selectionStart = position;
    this.selectionEnd = position;
    this.focus();
};
HTMLTextAreaElement.prototype.hasSelection = function () { //if the textarea has selection then return true
    if (this.selectionStart == this.selectionEnd) {
        return false;
    } else {
        return true;
    }
};
HTMLTextAreaElement.prototype.getSelectedText &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=17004</guid>
         <pubDate>Sun, 13 May 2012 23:54:40 +0000</pubDate>
         <content:encoded><![CDATA[<p>Normally the tab key moves to the next focusable thing. This inserts a tab character in instead.</p>
<pre><code>HTMLTextAreaElement.prototype.getCaretPosition = function () { //return the caret position of the textarea
    return this.selectionStart;
};
HTMLTextAreaElement.prototype.setCaretPosition = function (position) { //change the caret position of the textarea
    this.selectionStart = position;
    this.selectionEnd = position;
    this.focus();
};
HTMLTextAreaElement.prototype.hasSelection = function () { //if the textarea has selection then return true
    if (this.selectionStart == this.selectionEnd) {
        return false;
    } else {
        return true;
    }
};
HTMLTextAreaElement.prototype.getSelectedText = function () { //return the selection text
    return this.value.substring(this.selectionStart, this.selectionEnd);
};
HTMLTextAreaElement.prototype.setSelection = function (start, end) { //change the selection area of the textarea
    this.selectionStart = start;
    this.selectionEnd = end;
    this.focus();
};

var textarea = document.getElementsByTagName('textarea')[0]; 

textarea.onkeydown = function(event) {

    //support tab on textarea
    if (event.keyCode == 9) { //tab was pressed
        var newCaretPosition;
        newCaretPosition = textarea.getCaretPosition() + "    ".length;
        textarea.value = textarea.value.substring(0, textarea.getCaretPosition()) + "    " + textarea.value.substring(textarea.getCaretPosition(), textarea.value.length);
        textarea.setCaretPosition(newCaretPosition);
        return false;
    }
    if(event.keyCode == 8){ //backspace
        if (textarea.value.substring(textarea.getCaretPosition() - 4, textarea.getCaretPosition()) == "    ") { //it's a tab space
            var newCaretPosition;
            newCaretPosition = textarea.getCaretPosition() - 3;
            textarea.value = textarea.value.substring(0, textarea.getCaretPosition() - 3) + textarea.value.substring(textarea.getCaretPosition(), textarea.value.length);
            textarea.setCaretPosition(newCaretPosition);
        }
    }
    if(event.keyCode == 37){ //left arrow
        var newCaretPosition;
        if (textarea.value.substring(textarea.getCaretPosition() - 4, textarea.getCaretPosition()) == "    ") { //it's a tab space
            newCaretPosition = textarea.getCaretPosition() - 3;
            textarea.setCaretPosition(newCaretPosition);
        }
    }
    if(event.keyCode == 39){ //right arrow
        var newCaretPosition;
        if (textarea.value.substring(textarea.getCaretPosition() + 4, textarea.getCaretPosition()) == "    ") { //it's a tab space
            newCaretPosition = textarea.getCaretPosition() + 3;
            textarea.setCaretPosition(newCaretPosition);
        }
    }
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/gkWvf36Lkw4" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/support-tabs-in-textareas/</feedburner:origLink></item>
      <item>
         <title>Remove LI Elements From Output of wp_nav_menu</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/JALI12rPxSE/</link>
         <description>&lt;p&gt;You can remove or change the &lt;code&gt;&amp;#60;ul&amp;#62;&lt;/code&gt; container that you get by default with &lt;code&gt;wp_nav_menu&lt;/code&gt; (&lt;a rel="nofollow" target="_blank" href="http://codex.wordpress.org/Function_Reference/wp_nav_menu"&gt;codex&lt;/a&gt;) through parameters, but you can't remove the &lt;code&gt;&amp;#60;li&amp;#62;&lt;/code&gt; elements that wrap each menu item. This is how you can actually remove them:&lt;/p&gt;
&lt;code&gt;$menuParameters = array(
  'container'       =&amp;#62; false,
  'echo'            =&amp;#62; false,
  'items_wrap'      =&amp;#62; '%3$s',
  'depth'           =&amp;#62; 0,
);

echo strip_tags(wp_nav_menu( $menuParameters ), '&amp;#60;a&amp;#62;' );&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16950</guid>
         <pubDate>Mon, 07 May 2012 21:33:26 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can remove or change the <code>&lt;ul&gt;</code> container that you get by default with <code>wp_nav_menu</code> (<a rel="nofollow" target="_blank" href="http://codex.wordpress.org/Function_Reference/wp_nav_menu">codex</a>) through parameters, but you can't remove the <code>&lt;li&gt;</code> elements that wrap each menu item. This is how you can actually remove them:</p>
<pre><code>$menuParameters = array(
  'container'       =&gt; false,
  'echo'            =&gt; false,
  'items_wrap'      =&gt; '%3$s',
  'depth'           =&gt; 0,
);

echo strip_tags(wp_nav_menu( $menuParameters ), '&lt;a&gt;' );</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/JALI12rPxSE" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/remove-li-elements-from-output-of-wp_nav_menu/</feedburner:origLink></item>
      <item>
         <title>Remove Width and Height Attributes From Inserted Images</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/6XARm00_uMo/</link>
         <description>&lt;p&gt;When you upload an image through the WordPress media uploader and then insert it into the editor, it comes with width and height attributes. These are normally desirable, as it assists the browser in making the appropriate room for the image during layout. But if you want to remove the insert action from adding these attributes, you can add this code to you functions.php file or a functionality plugin of your own making:&lt;/p&gt;
&lt;code&gt;add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16937</guid>
         <pubDate>Sun, 06 May 2012 22:16:17 +0000</pubDate>
         <content:encoded><![CDATA[<p>When you upload an image through the WordPress media uploader and then insert it into the editor, it comes with width and height attributes. These are normally desirable, as it assists the browser in making the appropriate room for the image during layout. But if you want to remove the insert action from adding these attributes, you can add this code to you functions.php file or a functionality plugin of your own making:</p>
<pre><code>add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );

function remove_width_attribute( $html ) {
   $html = preg_replace( '/(width|height)="&#92;d*"&#92;s/', "", $html );
   return $html;
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/6XARm00_uMo" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/remove-width-and-height-attributes-from-inserted-images/</feedburner:origLink></item>
      <item>
         <title>Create Data URI’s</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/jaFq1EZTQp0/</link>
         <description>&lt;p&gt;These can be useful for embedding images into HTML/CSS/JS to save on HTTP requests, at the cost of maintainability. &lt;a rel="nofollow" target="_blank" href="http://css-tricks.com/data-uris/"&gt;More information.&lt;/a&gt; There are &lt;a rel="nofollow" target="_blank" href="http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/"&gt;online tools&lt;/a&gt; to do it, but if you want your own very simple utility, here's some PHP to do it:&lt;/p&gt;
&lt;code&gt;function data_uri($file, $mime) {
  $contents=file_get_contents($file);
  $base64=base64_encode($contents);
  echo "data:$mime;base64,$base64";
}&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16899</guid>
         <pubDate>Tue, 01 May 2012 14:31:15 +0000</pubDate>
         <content:encoded><![CDATA[<p>These can be useful for embedding images into HTML/CSS/JS to save on HTTP requests, at the cost of maintainability. <a rel="nofollow" target="_blank" href="http://css-tricks.com/data-uris/">More information.</a> There are <a rel="nofollow" target="_blank" href="http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/">online tools</a> to do it, but if you want your own very simple utility, here's some PHP to do it:</p>
<pre><code>function data_uri($file, $mime) {
  $contents=file_get_contents($file);
  $base64=base64_encode($contents);
  echo "data:$mime;base64,$base64";
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/jaFq1EZTQp0" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/create-data-uris/</feedburner:origLink></item>
      <item>
         <title>Detect Gists and Embed Them</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/2oE34VERH1c/</link>
         <description>&lt;p&gt;Just post a link to a &lt;a rel="nofollow" target="_blank" href="https://gist.github.com/"&gt;GitHub Gist&lt;/a&gt; and it will be nicely embedded. Or use the format this snippet provides and create the shortcode yourself. For your functions.php file:&lt;/p&gt;
&lt;code&gt;&amp;#60;?php
// [gist id="ID" file="FILE"]
function gist_shortcode($atts) {
  return sprintf(
    '&amp;#60;script src="https://gist.github.com/%s.js%s"&amp;#62;&amp;#60;/script&amp;#62;',
    $atts['id'],
    $atts['file'] ? '?file=' . $atts['file'] : ''
  );
} add_shortcode('gist','gist_shortcode');

// Remove this function if you don't want autoreplace gist links to shortcodes
function gist_shortcode_filter($content) {
  return preg_replace('/https:&amp;#92;/&amp;#92;/gist.github.com&amp;#92;/([&amp;#92;d]+)[&amp;#92;.js&amp;#92;?]*[&amp;#92;#]*file[=&amp;#124;_]+([&amp;#92;w&amp;#92;.]+)(?![^&amp;#60;]*&amp;#60;&amp;#92;/a&amp;#62;)/i', '[gist id="${1}" file="${2}"]', $content );
} add_filter( 'the_content', 'gist_shortcode_filter', &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16838</guid>
         <pubDate>Fri, 20 Apr 2012 01:19:28 +0000</pubDate>
         <content:encoded><![CDATA[<p>Just post a link to a <a rel="nofollow" target="_blank" href="https://gist.github.com/">GitHub Gist</a> and it will be nicely embedded. Or use the format this snippet provides and create the shortcode yourself. For your functions.php file:</p>
<pre><code>&lt;?php
// [gist id="ID" file="FILE"]
function gist_shortcode($atts) {
  return sprintf(
    '&lt;script src="https://gist.github.com/%s.js%s"&gt;&lt;/script&gt;',
    $atts['id'],
    $atts['file'] ? '?file=' . $atts['file'] : ''
  );
} add_shortcode('gist','gist_shortcode');

// Remove this function if you don't want autoreplace gist links to shortcodes
function gist_shortcode_filter($content) {
  return preg_replace('/https:&#92;/&#92;/gist.github.com&#92;/([&#92;d]+)[&#92;.js&#92;?]*[&#92;#]*file[=|_]+([&#92;w&#92;.]+)(?![^&lt;]*&lt;&#92;/a&gt;)/i', '[gist id="${1}" file="${2}"]', $content );
} add_filter( 'the_content', 'gist_shortcode_filter', 9);
?&gt;</code></pre>
<p>Any of these formats will work:</p>
<ul>
<li>https://gist.github.com/1147076</li>
<li>https://gist.github.com/1147076#file_annotated.js</li>
<li>https://gist.github.com/1147076.js?file=annotated.js</li>
<li>[gist id=1147076]</li>
<li>[gist id=1147076 file=annotated.js]</li>
</ul><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/2oE34VERH1c" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/detect-gists-and-embed-them/</feedburner:origLink></item>
      <item>
         <title>Glowing Blue Input Highlights</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/PgHKPS_lm1s/</link>
         <description>&lt;p&gt;Like mid-2012 Twitter.&lt;/p&gt;
&lt;code&gt;input[type=text], textarea {
  -webkit-transition: all 0.30s ease-in-out;
  -moz-transition: all 0.30s ease-in-out;
  -ms-transition: all 0.30s ease-in-out;
  -o-transition: all 0.30s ease-in-out;
  outline: none;
  padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;
  border: 1px solid #DDDDDD;
}

input[type=text]:focus, textarea:focus {
  box-shadow: 0 0 5px rgba(81, 203, 238, 1);
  padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;
  border: 1px solid rgba(81, 203, 238, 1);
}&lt;/code&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_blank" href="http://jsfiddle.net/chriscoyier/X79M8/" class="button"&gt;View Demo&lt;/a&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16791</guid>
         <pubDate>Wed, 11 Apr 2012 20:55:14 +0000</pubDate>
         <content:encoded><![CDATA[<p>Like mid-2012 Twitter.</p>
<pre><code>input[type=text], textarea {
  -webkit-transition: all 0.30s ease-in-out;
  -moz-transition: all 0.30s ease-in-out;
  -ms-transition: all 0.30s ease-in-out;
  -o-transition: all 0.30s ease-in-out;
  outline: none;
  padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;
  border: 1px solid #DDDDDD;
}

input[type=text]:focus, textarea:focus {
  box-shadow: 0 0 5px rgba(81, 203, 238, 1);
  padding: 3px 0px 3px 3px;
  margin: 5px 1px 3px 0px;
  border: 1px solid rgba(81, 203, 238, 1);
}</code></pre>
<p><a rel="nofollow" target="_blank" href="http://jsfiddle.net/chriscoyier/X79M8/" class="button">View Demo</a></p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/PgHKPS_lm1s" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/glowing-blue-input-highlights/</feedburner:origLink></item>
      <item>
         <title>Mixins for Rem Font Sizing</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/fj9Vq7pAaKY/</link>
         <description>&lt;p&gt;The &lt;code&gt;rem&lt;/code&gt; font-size unit is similar to &lt;code&gt;em&lt;/code&gt;, only instead of cascading it's always relative to the root (html) element (&lt;a rel="nofollow" target="_blank" href="http://snook.ca/archives/html_and_css/font-size-with-rem"&gt;more information&lt;/a&gt;). This has pretty good modern browser support, it's just IE 8 and down we need to provide &lt;code&gt;px&lt;/code&gt; fallbacks for.&lt;/p&gt;
&lt;p&gt;Instead of repeating ourselves everywhere, we can use a LESS or SASS mixins to keep it clean. These mixins assumes:&lt;/p&gt;
&lt;code&gt;html {
  font-size: 62.5%; /* Sets up the Base 10 stuff */
}&lt;/code&gt;
&lt;code&gt;.font-size(@sizeValue){
  @remValue: &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16776</guid>
         <pubDate>Tue, 10 Apr 2012 19:40:24 +0000</pubDate>
         <content:encoded><![CDATA[<p>The <code>rem</code> font-size unit is similar to <code>em</code>, only instead of cascading it's always relative to the root (html) element (<a rel="nofollow" target="_blank" href="http://snook.ca/archives/html_and_css/font-size-with-rem">more information</a>). This has pretty good modern browser support, it's just IE 8 and down we need to provide <code>px</code> fallbacks for.</p>
<p>Instead of repeating ourselves everywhere, we can use a LESS or SASS mixins to keep it clean. These mixins assumes:</p>
<pre><code>html {
  font-size: 62.5%; /* Sets up the Base 10 stuff */
}</code></pre>
<pre><code>.font-size(@sizeValue){
  @remValue: @sizeValue;
  @pxValue: (@sizeValue * 10);
  font-size: ~"@{pxValue}px";
  font-size: ~"@{remValue}rem";
}</code></pre>
<pre><code>@mixin font-size($sizeValue: 1.6){
  font-size: ($sizeValue * 10) + px;
  font-size: $sizeValue + rem;
}</code></pre>
<h4>Usage</h4>
<pre><code>p {
  .font-size(13);
}</code></pre>
<pre><code>p {
  @include font-size(13);
}</code></pre>
<p>(Thanks <a rel="nofollow" target="_blank" href="http://thefstopdesign.com/">Gabe Luethje</a>)</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/fj9Vq7pAaKY" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/less-mixin-for-rem-font-sizing/</feedburner:origLink></item>
      <item>
         <title>Get The First Image From a Post</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/OajLmmuoGNE/</link>
         <description>&lt;p&gt;Let's say you wanted to use the &lt;a rel="nofollow" target="_blank" href="http://codex.wordpress.org/Post_Thumbnails"&gt;post thumbnail feature&lt;/a&gt; of WordPress, but had a whole archive of posts that would take too much time to go through. For new posts, you can be specific and use the feature as intended. For old posts, you just want to use the first image it finds in the content for the thumbnail, or a default if none present. &lt;/p&gt;
&lt;p&gt;Add this to functions.php or make a &lt;a rel="nofollow" target="_blank" href="http://wpcandy.com/teaches/how-to-create-a-functionality-plugin"&gt;functionality plugin&lt;/a&gt;: &lt;/p&gt;
&lt;code&gt;function catch_that_image() {
  global &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16732</guid>
         <pubDate>Wed, 04 Apr 2012 14:32:33 +0000</pubDate>
         <content:encoded><![CDATA[<p>Let's say you wanted to use the <a rel="nofollow" target="_blank" href="http://codex.wordpress.org/Post_Thumbnails">post thumbnail feature</a> of WordPress, but had a whole archive of posts that would take too much time to go through. For new posts, you can be specific and use the feature as intended. For old posts, you just want to use the first image it finds in the content for the thumbnail, or a default if none present. </p>
<p>Add this to functions.php or make a <a rel="nofollow" target="_blank" href="http://wpcandy.com/teaches/how-to-create-a-functionality-plugin">functionality plugin</a>: </p>
<pre><code>function catch_that_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/&lt;img.+src=[&#92;'"]([^&#92;'"]+)[&#92;'"].*&gt;/i', $post-&gt;post_content, $matches);
  $first_img = $matches[1][0];

  if(empty($first_img)) {
    $first_img = "/path/to/default.png";
  }
  return $first_img;
}</code></pre>
<p>To use it, use this code in <a rel="nofollow" target="_blank" href="http://codex.wordpress.org/The_Loop">the loop</a>:</p>
<pre><code>if ( get_the_post_thumbnail($post_id) != '' ) {

  echo '&lt;a href="'; the_permalink(); echo '" class="thumbnail-wrapper"&gt;';
   the_post_thumbnail();
  echo '&lt;/a&gt;';

} else {

 echo '&lt;a href="'; the_permalink(); echo '" class="thumbnail-wrapper"&gt;';
 echo '&lt;img src="';
 echo catch_that_image();
 echo '" alt="" /&gt;';
 echo '&lt;/a&gt;';

}</code></pre>
<p>I found that <a rel="nofollow" target="_blank" href="http://codex.wordpress.org/Function_Reference/has_post_thumbnail">has_post_thumbnail</a> wasn't as reliable as the logic above.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/OajLmmuoGNE" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/get-the-first-image-from-a-post/</feedburner:origLink></item>
      <item>
         <title>Lazy Loading Images</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/zAxIl9Vw9p8/</link>
         <description>&lt;p&gt;Use a &lt;code&gt;blank.gif&lt;/code&gt; as the &lt;code&gt;src&lt;/code&gt; of images, and include the &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; of the final image. &lt;/p&gt;
&lt;code&gt;&amp;#60;img src="blank.gif" class="lazy" data-src="/images/full-size.jpg" width="240" height="152"&amp;#62;&amp;#60;/a&amp;#62;​&lt;/code&gt;
&lt;code&gt;/* lazyload.js (c) Lorenzo Giuliani
 * MIT License (http://www.opensource.org/licenses/mit-license.html)
 *
 * expects a list of:
 * `&amp;#60;img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy"&amp;#62;`
 */

!function(window){
  var $q = function(q, res){
        if (document.querySelectorAll) {
          res = document.querySelectorAll(q);
        } else {
          var d=document
            , a=d.styleSheets[0] &amp;#124;&amp;#124; d.createStyleSheet();
          a.addRule(q,'f:b');
          for(var l=d.all,b=0,c=[],f=l.length;b&amp;#60;f;b++)
            l[b].currentStyle.f &amp;#38;&amp;#38; c.push(l[b]);

          a.removeRule(0);
          res = c;
        }
        return &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16614</guid>
         <pubDate>Tue, 27 Mar 2012 22:25:06 +0000</pubDate>
         <content:encoded><![CDATA[<p>Use a <code>blank.gif</code> as the <code>src</code> of images, and include the <code>width</code> and <code>height</code> of the final image. </p>
<pre><code>&lt;img src="blank.gif" class="lazy" data-src="/images/full-size.jpg" width="240" height="152"&gt;&lt;/a&gt;​</code></pre>
<pre><code>/* lazyload.js (c) Lorenzo Giuliani
 * MIT License (http://www.opensource.org/licenses/mit-license.html)
 *
 * expects a list of:
 * `&lt;img src="blank.gif" data-src="my_image.png" width="600" height="400" class="lazy"&gt;`
 */

!function(window){
  var $q = function(q, res){
        if (document.querySelectorAll) {
          res = document.querySelectorAll(q);
        } else {
          var d=document
            , a=d.styleSheets[0] || d.createStyleSheet();
          a.addRule(q,'f:b');
          for(var l=d.all,b=0,c=[],f=l.length;b&lt;f;b++)
            l[b].currentStyle.f &amp;&amp; c.push(l[b]);

          a.removeRule(0);
          res = c;
        }
        return res;
      }
    , addEventListener = function(evt, fn){
        window.addEventListener
          ? this.addEventListener(evt, fn, false)
          : (window.attachEvent)
            ? this.attachEvent('on' + evt, fn)
            : this['on' + evt] = fn;
      }
    , _has = function(obj, key) {
        return Object.prototype.hasOwnProperty.call(obj, key);
      }
    ;

  function loadImage (el, fn) {
    var img = new Image()
      , src = el.getAttribute('data-src');
    img.onload = function() {
      if (!! el.parent)
        el.parent.replaceChild(img, el)
      else
        el.src = src;

      fn? fn() : null;
    }
    img.src = src;
  }

  function elementInViewport(el) {
    var rect = el.getBoundingClientRect()

    return (
       rect.top    &gt;= 0
    &amp;&amp; rect.left   &gt;= 0
    &amp;&amp; rect.top &lt;= (window.innerHeight || document.documentElement.clientHeight)
    )
  }

    var images = new Array()
      , query = $q('img.lazy')
      , processScroll = function(){
          for (var i = 0; i &lt; images.length; i++) {
            if (elementInViewport(images[i])) {
              loadImage(images[i], function () {
                images.splice(i, i);
              });
            }
          };
        }
      ;
    // Array.prototype.slice.call is not callable under our lovely IE8
    for (var i = 0; i &lt; query.length; i++) {
      images.push(query[i]);
    };

    processScroll();
    addEventListener('scroll',processScroll);

}(this);​</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/zAxIl9Vw9p8" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/lazy-loading-images/</feedburner:origLink></item>
      <item>
         <title>Year Shortcode</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/3hRlh_ec18k/</link>
         <description>&lt;p&gt;For the functions.php file:&lt;/p&gt;
&lt;code&gt;function year_shortcode() {
  $year = date('Y');
  return $year;
}
add_shortcode('year', 'year_shortcode');&lt;/code&gt;
&lt;h4&gt;Usage&lt;/h4&gt;
&lt;p&gt;Use [year] in your posts.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16456</guid>
         <pubDate>Thu, 08 Mar 2012 19:12:58 +0000</pubDate>
         <content:encoded><![CDATA[<p>For the functions.php file:</p>
<pre><code>function year_shortcode() {
  $year = date('Y');
  return $year;
}
add_shortcode('year', 'year_shortcode');</code></pre>
<h4>Usage</h4>
<p>Use [year] in your posts.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/3hRlh_ec18k" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/wordpress/year-shortcode/</feedburner:origLink></item>
      <item>
         <title>Get Object Size</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/eioKqm86cBI/</link>
         <description>&lt;p&gt;As in, the number of keys. &lt;/p&gt;
&lt;code&gt;function objectSize(the_object) {
  /* function to validate the existence of each key in the object to get the number of valid keys. */
  var object_size = 0;
  for (key in the_object){
    if (the_object.hasOwnProperty(key)) {
      object_size++;
    }
  }
  return object_size;
}&lt;/code&gt;
&lt;h4&gt;Usage&lt;/h4&gt;
&lt;code&gt;// Arbitrary object
var something = {
  dog: "cat",
  cat: "dog"
}

console.log(objectSize(something));
// Logs: 2&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16453</guid>
         <pubDate>Thu, 08 Mar 2012 18:58:51 +0000</pubDate>
         <content:encoded><![CDATA[<p>As in, the number of keys. </p>
<pre><code>function objectSize(the_object) {
  /* function to validate the existence of each key in the object to get the number of valid keys. */
  var object_size = 0;
  for (key in the_object){
    if (the_object.hasOwnProperty(key)) {
      object_size++;
    }
  }
  return object_size;
}</code></pre>
<h4>Usage</h4>
<pre><code>// Arbitrary object
var something = {
  dog: "cat",
  cat: "dog"
}

console.log(objectSize(something));
// Logs: 2</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/eioKqm86cBI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/get-object-size/</feedburner:origLink></item>
      <item>
         <title>Corner Ribbon</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/1vaCocfcQdo/</link>
         <description>&lt;code&gt;&amp;#60;div class="wrapper"&amp;#62;
       &amp;#60;div class="ribbon-wrapper-green"&amp;#62;&amp;#60;div class="ribbon-green"&amp;#62;NEWS&amp;#60;/div&amp;#62;&amp;#60;/div&amp;#62;
&amp;#60;/div&amp;#62;​&lt;/code&gt;
&lt;code&gt;.wrapper {
  margin: 50px auto;
  width: 280px;
  height: 370px;
  background: white;
  border-radius: 10px;
  -webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 8px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 8px rgba(0,0,0,0.3);
  position: relative;
  z-index: 90;
}

.ribbon-wrapper-green {
  width: 85px;
  height: 88px;
  overflow: hidden;
  position: absolute;
  top: -3px;
  right: -3px;
}

.ribbon-green {
  font: bold 15px Sans-Serif;
  color: #333;
  text-align: center;
  text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg);
  position: relative;
  padding: &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16320</guid>
         <pubDate>Fri, 17 Feb 2012 22:57:49 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>&lt;div class="wrapper"&gt;
       &lt;div class="ribbon-wrapper-green"&gt;&lt;div class="ribbon-green"&gt;NEWS&lt;/div&gt;&lt;/div&gt;
&lt;/div&gt;​</code></pre>
<pre><code>.wrapper {
  margin: 50px auto;
  width: 280px;
  height: 370px;
  background: white;
  border-radius: 10px;
  -webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 8px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 8px rgba(0,0,0,0.3);
  position: relative;
  z-index: 90;
}

.ribbon-wrapper-green {
  width: 85px;
  height: 88px;
  overflow: hidden;
  position: absolute;
  top: -3px;
  right: -3px;
}

.ribbon-green {
  font: bold 15px Sans-Serif;
  color: #333;
  text-align: center;
  text-shadow: rgba(255,255,255,0.5) 0px 1px 0px;
  -webkit-transform: rotate(45deg);
  -moz-transform:    rotate(45deg);
  -ms-transform:     rotate(45deg);
  -o-transform:      rotate(45deg);
  position: relative;
  padding: 7px 0;
  left: -5px;
  top: 15px;
  width: 120px;
  background-color: #BFDC7A;
  background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
  background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
  background-image:    -moz-linear-gradient(top, #BFDC7A, #8EBF45);
  background-image:     -ms-linear-gradient(top, #BFDC7A, #8EBF45);
  background-image:      -o-linear-gradient(top, #BFDC7A, #8EBF45);
  color: #6a6340;
  -webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
  -moz-box-shadow:    0px 0px 3px rgba(0,0,0,0.3);
  box-shadow:         0px 0px 3px rgba(0,0,0,0.3);
}

.ribbon-green:before, .ribbon-green:after {
  content: "";
  border-top:   3px solid #6e8900;
  border-left:  3px solid transparent;
  border-right: 3px solid transparent;
  position:absolute;
  bottom: -3px;
}

.ribbon-green:before {
  left: 0;
}
.ribbon-green:after {
  right: 0;
}​</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/1vaCocfcQdo" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/corner-ribbon/</feedburner:origLink></item>
      <item>
         <title>Layered Paper</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/mTbfrehZqRI/</link>
         <description>&lt;code&gt;&amp;#60;div class="layered-paper"&amp;#62;
    Howdy
&amp;#60;/div&amp;#62;&lt;/code&gt;
&lt;code&gt;.layered-paper {
    background: #eee;
    box-shadow:
        0 1px 1px rgba(0,0,0,0.15), /* The top layer shadow */
        0 10px 0 -5px #eee, /* The second layer */
        0 10px 1px -4px rgba(0,0,0,0.15), /* The second layer shadow */
        0 20px 0 -10px #eee, /* The third layer */
        0 20px 1px -9px rgba(0,0,0,0.15); /* The third layer shadow */
}&lt;/code&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_blank" href="http://jsfiddle.net/chriscoyier/PBzLJ/" class="button"&gt;View Demo&lt;/a&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16167</guid>
         <pubDate>Tue, 31 Jan 2012 22:39:29 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>&lt;div class="layered-paper"&gt;
    Howdy
&lt;/div&gt;</code></pre>
<pre><code>.layered-paper {
    background: #eee;
    box-shadow:
        0 1px 1px rgba(0,0,0,0.15), /* The top layer shadow */
        0 10px 0 -5px #eee, /* The second layer */
        0 10px 1px -4px rgba(0,0,0,0.15), /* The second layer shadow */
        0 20px 0 -10px #eee, /* The third layer */
        0 20px 1px -9px rgba(0,0,0,0.15); /* The third layer shadow */
}</code></pre>
<p><img src="http://cdn.css-tricks.com/wp-content/uploads/2012/01/layeredpaper.png" alt="" title="layeredpaper" width="502" height="127" class="alignnone size-full wp-image-16168"/></p>
<p><a rel="nofollow" target="_blank" href="http://jsfiddle.net/chriscoyier/PBzLJ/" class="button">View Demo</a></p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/mTbfrehZqRI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/layered-paper/</feedburner:origLink></item>
      <item>
         <title>Prevent Long URL’s From Breaking Out of Container</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/cBaiE77C7Vw/</link>
         <description>&lt;p&gt;Or any long bit of text, really.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;code&gt;.comment-text {
   word-wrap: break-word;
}&lt;/code&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;A more robust browser support, you'll need more (&lt;a rel="nofollow" target="_blank" href="http://blog.kenneth.io/blog/2012/03/04/word-wrapping-hypernation-using-css/"&gt;via&lt;/a&gt;): &lt;/p&gt;
&lt;code&gt;-ms-word-break: break-all;
     word-break: break-all;

     // Non standard for webkit
     word-break: break-word;

-webkit-hyphens: auto;
   -moz-hyphens: auto;
        hyphens: auto;&lt;/code&gt;
&lt;p&gt;The above works in Internet Explorer 8+, Firefox 6+, iOS 4.2, Safari 5.1+ and Chrome 13+.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16145</guid>
         <pubDate>Tue, 31 Jan 2012 03:31:45 +0000</pubDate>
         <content:encoded><![CDATA[<p>Or any long bit of text, really.</p>
<p><img src="http://cdn.css-tricks.com/wp-content/uploads/2012/01/commentbreak.png" alt="" title="commentbreak" width="856" height="172" class="alignnone size-full wp-image-16146"/></p>
<pre><code>.comment-text {
   word-wrap: break-word;
}</code></pre>
<p><img src="http://cdn.css-tricks.com/wp-content/uploads/2012/01/fixed.png" alt="" title="fixed" width="829" height="205" class="alignnone size-full wp-image-16147"/></p>
<p>A more robust browser support, you'll need more (<a rel="nofollow" target="_blank" href="http://blog.kenneth.io/blog/2012/03/04/word-wrapping-hypernation-using-css/">via</a>): </p>
<pre><code>-ms-word-break: break-all;
     word-break: break-all;

     // Non standard for webkit
     word-break: break-word;

-webkit-hyphens: auto;
   -moz-hyphens: auto;
        hyphens: auto;</code></pre>
<p>The above works in Internet Explorer 8+, Firefox 6+, iOS 4.2, Safari 5.1+ and Chrome 13+.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/cBaiE77C7Vw" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/</feedburner:origLink></item>
      <item>
         <title>Remove Specific Value from Array</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/M5WP03U6hMI/</link>
         <description>&lt;code&gt;var arr = [1, 2, 3, 4, 5];
var removeItem = 2;   

arr = $.grep(arr, function(value) {
  return value != removeItem;
});&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16127</guid>
         <pubDate>Sun, 29 Jan 2012 21:46:57 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>var arr = [1, 2, 3, 4, 5];
var removeItem = 2;   

arr = $.grep(arr, function(value) {
  return value != removeItem;
});</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/M5WP03U6hMI" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/remove-specific-value-from-array/</feedburner:origLink></item>
      <item>
         <title>Redirect to SSL</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/2gOtjTBuKZY/</link>
         <description>&lt;code&gt;window.location = "https://" + window.location.hostname + window.location.pathname + window.location.search;&lt;/code&gt;
&lt;p&gt;You might wanna test if window.location.href doesn't start with "https" before doing that, so you don't redirect unless you have to.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16101</guid>
         <pubDate>Sat, 28 Jan 2012 22:45:42 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>window.location = "https://" + window.location.hostname + window.location.pathname + window.location.search;</code></pre>
<p>You might wanna test if window.location.href doesn't start with "https" before doing that, so you don't redirect unless you have to.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/2gOtjTBuKZY" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/redirect-to-ssl/</feedburner:origLink></item>
      <item>
         <title>Paste Events</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/Zb1yQrAfd6o/</link>
         <description>&lt;code&gt;$.fn.pasteEvents = function( delay ) {
    if (delay == undefined) delay = 20;
    return $(this).each(function() {
        var $el = $(this);
        $el.on("paste", function() {
            $el.trigger("prepaste");
            setTimeout(function() { $el.trigger("postpaste"); }, delay);
        });
    });
};&lt;/code&gt;
&lt;p&gt;Call this plugin on an element, then you get callback events for before and after pasting:&lt;/p&gt;
&lt;code&gt;$("#some-element").on("postpaste", function() {
    // do something
}).pasteEvents();&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16076</guid>
         <pubDate>Wed, 25 Jan 2012 23:33:47 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code>$.fn.pasteEvents = function( delay ) {
    if (delay == undefined) delay = 20;
    return $(this).each(function() {
        var $el = $(this);
        $el.on("paste", function() {
            $el.trigger("prepaste");
            setTimeout(function() { $el.trigger("postpaste"); }, delay);
        });
    });
};</code></pre>
<p>Call this plugin on an element, then you get callback events for before and after pasting:</p>
<pre><code>$("#some-element").on("postpaste", function() {
    // do something
}).pasteEvents();</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/Zb1yQrAfd6o" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/paste-events/</feedburner:origLink></item>
      <item>
         <title>Detect Location by IP</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/9fqOiik6dpo/</link>
         <description>&lt;p&gt;Returns "City, State" if found otherwise the default set at the top.&lt;/p&gt;
&lt;code&gt;function detect_city($ip) {

        $default = 'UNKNOWN';

        if (!is_string($ip) &amp;#124;&amp;#124; strlen($ip) &amp;#60; 1 &amp;#124;&amp;#124; $ip == '127.0.0.1' &amp;#124;&amp;#124; $ip == 'localhost')
            $ip = '8.8.8.8';

        $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';

        $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
        $ch = curl_init();

        $curl_opt = array(
            CURLOPT_FOLLOWLOCATION  =&amp;#62; 1,
            CURLOPT_HEADER      =&amp;#62; 0,
            CURLOPT_RETURNTRANSFER  =&amp;#62; 1,
            CURLOPT_USERAGENT   =&amp;#62; $curlopt_useragent,
            CURLOPT_URL       =&amp;#62; $url,
            CURLOPT_TIMEOUT         =&amp;#62; 1,
            CURLOPT_REFERER         &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16030</guid>
         <pubDate>Tue, 17 Jan 2012 03:19:43 +0000</pubDate>
         <content:encoded><![CDATA[<p>Returns "City, State" if found otherwise the default set at the top.</p>
<pre><code>function detect_city($ip) {

        $default = 'UNKNOWN';

        if (!is_string($ip) || strlen($ip) &lt; 1 || $ip == '127.0.0.1' || $ip == 'localhost')
            $ip = '8.8.8.8';

        $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)';

        $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip);
        $ch = curl_init();

        $curl_opt = array(
            CURLOPT_FOLLOWLOCATION  =&gt; 1,
            CURLOPT_HEADER      =&gt; 0,
            CURLOPT_RETURNTRANSFER  =&gt; 1,
            CURLOPT_USERAGENT   =&gt; $curlopt_useragent,
            CURLOPT_URL       =&gt; $url,
            CURLOPT_TIMEOUT         =&gt; 1,
            CURLOPT_REFERER         =&gt; 'http://' . $_SERVER['HTTP_HOST'],
        );

        curl_setopt_array($ch, $curl_opt);

        $content = curl_exec($ch);

        if (!is_null($curl_info)) {
            $curl_info = curl_getinfo($ch);
        }

        curl_close($ch);

        if ( preg_match('{&lt;li&gt;City : ([^&lt;]*)&lt;/li&gt;}i', $content, $regs) )  {
            $city = $regs[1];
        }
        if ( preg_match('{&lt;li&gt;State/Province : ([^&lt;]*)&lt;/li&gt;}i', $content, $regs) )  {
            $state = $regs[1];
        }

        if( $city!='' &amp;&amp; $state!='' ){
          $location = $city . ', ' . $state;
          return $location;
        }else{
          return $default;
        }

}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/9fqOiik6dpo" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/detect-location-by-ip/</feedburner:origLink></item>
      <item>
         <title>Send a Text Message</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/qST2RAssrak/</link>
         <description>&lt;p&gt;You'll need a &lt;a rel="nofollow" target="_blank" href="http://www.textmagic.com/"&gt;TextMagic account&lt;/a&gt; and to download their PHP helper which they provide after signing up.&lt;/p&gt;
&lt;code&gt;// Include the TextMagic PHP lib
require('textmagic-sms-api-php/TextMagicAPI.php');

// Set the username and password information
$username = 'myusername';
$password = 'mypassword';

// Create a new instance of TM
$router = new TextMagicAPI(array(
	'username' =&amp;#62; $username,
	'password' =&amp;#62; $password
));

// Send a text message to '999-123-4567'
$result = $router-&amp;#62;send('Wake up!', array(9991234567), true);

// result:  Result is: Array ( [messages] =&amp;#62; Array ( [19896128] =&amp;#62; &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16028</guid>
         <pubDate>Tue, 17 Jan 2012 03:17:31 +0000</pubDate>
         <content:encoded><![CDATA[<p>You'll need a <a rel="nofollow" target="_blank" href="http://www.textmagic.com/">TextMagic account</a> and to download their PHP helper which they provide after signing up.</p>
<pre><code>// Include the TextMagic PHP lib
require('textmagic-sms-api-php/TextMagicAPI.php');

// Set the username and password information
$username = 'myusername';
$password = 'mypassword';

// Create a new instance of TM
$router = new TextMagicAPI(array(
	'username' =&gt; $username,
	'password' =&gt; $password
));

// Send a text message to '999-123-4567'
$result = $router-&gt;send('Wake up!', array(9991234567), true);

// result:  Result is: Array ( [messages] =&gt; Array ( [19896128] =&gt; 9991234567 ) [sent_text] =&gt; Wake up! [parts_count] =&gt; 1 )</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/qST2RAssrak" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/send-a-text-message/</feedburner:origLink></item>
      <item>
         <title>Remove Inline Styles</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/6MRD496ZPPQ/</link>
         <description>&lt;p&gt;This function also preserves hidden content.&lt;/p&gt;
&lt;code&gt;function remove_style(all) {
  var i = all.length;
  var j, is_hidden;

  // Presentational attributes.
  var attr = [
    'align',
    'background',
    'bgcolor',
    'border',
    'cellpadding',
    'cellspacing',
    'color',
    'face',
    'height',
    'hspace',
    'marginheight',
    'marginwidth',
    'noshade',
    'nowrap',
    'valign',
    'vspace',
    'width',
    'vlink',
    'alink',
    'text',
    'link',
    'frame',
    'frameborder',
    'clear',
    'scrolling',
    'style'
  ];

  var attr_len = attr.length;

  while (i--) {
    is_hidden = (all[i].style.display === 'none');

    j = attr_len;

    while (j--) {
      all[i].removeAttribute(attr[j]);
    }

    // Re-hide display:none elements,
    // so they can be toggled &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=16021</guid>
         <pubDate>Mon, 16 Jan 2012 20:08:59 +0000</pubDate>
         <content:encoded><![CDATA[<p>This function also preserves hidden content.</p>
<pre><code>function remove_style(all) {
  var i = all.length;
  var j, is_hidden;

  // Presentational attributes.
  var attr = [
    'align',
    'background',
    'bgcolor',
    'border',
    'cellpadding',
    'cellspacing',
    'color',
    'face',
    'height',
    'hspace',
    'marginheight',
    'marginwidth',
    'noshade',
    'nowrap',
    'valign',
    'vspace',
    'width',
    'vlink',
    'alink',
    'text',
    'link',
    'frame',
    'frameborder',
    'clear',
    'scrolling',
    'style'
  ];

  var attr_len = attr.length;

  while (i--) {
    is_hidden = (all[i].style.display === 'none');

    j = attr_len;

    while (j--) {
      all[i].removeAttribute(attr[j]);
    }

    // Re-hide display:none elements,
    // so they can be toggled via JS.
    if (is_hidden) {
      all[i].style.display = 'none';
      is_hidden = false;
    }
  }
}</code></pre>
<h4>Usage</h4>
<p>Call the function like this:</p>
<pre><code>var all = document.getElementsByTagName('*');
remove_style(all);</code></pre>
<p>Note: Selecting all elements in the page via a wildcard query could be slow, depending on how many elements are in the page. You could use a smaller set of elements to be more performant:</p>
<pre><code>var set = document.getElementById('foo').getElementsByTagName('bar');
remove_style(set);</code></pre>
<p><a rel="nofollow" target="_blank" href="https://gist.github.com/262366">Code by Nathan Smith.</a></p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/6MRD496ZPPQ" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/javascript/remove-inline-styles/</feedburner:origLink></item>
      <item>
         <title>Convert Accented Characters</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/NdLHwV8i69I/</link>
         <description>&lt;p&gt;For instance, if you want to use a string as part of a URL but need to make it safe for that kind of use.&lt;/p&gt;
&lt;code&gt;function replace_accents($str) {
   $str = htmlentities($str, ENT_COMPAT, "UTF-8");
   $str = preg_replace('/&amp;#38;([a-zA-Z])(uml&amp;#124;acute&amp;#124;grave&amp;#124;circ&amp;#124;tilde);/','$1',$str);
   return html_entity_decode($str);
}&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=15580</guid>
         <pubDate>Thu, 15 Dec 2011 01:14:11 +0000</pubDate>
         <content:encoded><![CDATA[<p>For instance, if you want to use a string as part of a URL but need to make it safe for that kind of use.</p>
<pre><code>function replace_accents($str) {
   $str = htmlentities($str, ENT_COMPAT, "UTF-8");
   $str = preg_replace('/&amp;([a-zA-Z])(uml|acute|grave|circ|tilde);/','$1',$str);
   return html_entity_decode($str);
}</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/NdLHwV8i69I" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/php/convert-accented-characters/</feedburner:origLink></item>
      <item>
         <title>Base64 Encode of 1x1px Transparent GIF</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/ITLu1jTl5bk/</link>
         <description>&lt;p&gt;Just in case you need one. You can stretch it out to fill space as needed.&lt;/p&gt;
&lt;code&gt;&amp;#60;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"&amp;#62;&lt;/code&gt;
&lt;p&gt;Or a black one:&lt;/p&gt;
&lt;code&gt;&amp;#60;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="&amp;#62;&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=15547</guid>
         <pubDate>Mon, 12 Dec 2011 20:02:58 +0000</pubDate>
         <content:encoded><![CDATA[<p>Just in case you need one. You can stretch it out to fill space as needed.</p>
<pre><code>&lt;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"&gt;</code></pre>
<p>Or a black one:</p>
<pre><code>&lt;img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs="&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/ITLu1jTl5bk" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/base64-encode-of-1x1px-transparent-gif/</feedburner:origLink></item>
      <item>
         <title>Post Data to an iframe</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/iPAc6MawsOs/</link>
         <description>&lt;p&gt;Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute.&lt;/p&gt;
&lt;code&gt;&amp;#60;form action="iframe.php" target="my-iframe" method="post"&amp;#62;

  &amp;#60;label for="text"&amp;#62;Some text:&amp;#60;/label&amp;#62;
  &amp;#60;input type="text" name="text" id="text"&amp;#62;

  &amp;#60;input type="submit" value="post"&amp;#62;

&amp;#60;/form&amp;#62;

&amp;#60;iframe name="my-iframe" src="iframe.php"&amp;#62;&amp;#60;/iframe&amp;#62;&lt;/code&gt;
&lt;p&gt;The outer page doesn't even reload. But it might appear to at first glance since many browsers run the page-loading spinner in the tab when an iframe reloads.&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=15365</guid>
         <pubDate>Fri, 02 Dec 2011 03:59:39 +0000</pubDate>
         <content:encoded><![CDATA[<p>Doesn't take any JavaScript or anything. You just have the form's target attribute match the iframe's name attribute.</p>
<pre><code>&lt;form action="iframe.php" target="my-iframe" method="post"&gt;

  &lt;label for="text"&gt;Some text:&lt;/label&gt;
  &lt;input type="text" name="text" id="text"&gt;

  &lt;input type="submit" value="post"&gt;

&lt;/form&gt;

&lt;iframe name="my-iframe" src="iframe.php"&gt;&lt;/iframe&gt;</code></pre>
<p>The outer page doesn't even reload. But it might appear to at first glance since many browsers run the page-loading spinner in the tab when an iframe reloads.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/iPAc6MawsOs" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/post-data-to-an-iframe/</feedburner:origLink></item>
      <item>
         <title>Animate Height/Width to “Auto”</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/O9dLiyD3630/</link>
         <description>&lt;p&gt;It's not possible to do &lt;code&gt;thing.animate({ "height": "auto" });&lt;/code&gt;. So this is Darcy Clarke's method to allow that to work. You essentially clone the element, remove the fixed heights currently inflicting the element, and measure/save the value. Then you animate the real element to that value.&lt;/p&gt;
&lt;code&gt;jQuery.fn.animateAuto = function(prop, speed, callback){
    var elem, height, width;
    return this.each(function(i, el){
        el = jQuery(el), elem = el.clone().css({"height":"auto","width":"auto"}).appendTo("body");
        height = elem.css("height"),
        width = elem.css("width"),
        elem.remove();

        if(prop === "height")
            el.animate({"height":height}, speed, callback);
        else if(prop &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=15342</guid>
         <pubDate>Thu, 01 Dec 2011 05:01:37 +0000</pubDate>
         <content:encoded><![CDATA[<p>It's not possible to do <code>thing.animate({ "height": "auto" });</code>. So this is Darcy Clarke's method to allow that to work. You essentially clone the element, remove the fixed heights currently inflicting the element, and measure/save the value. Then you animate the real element to that value.</p>
<pre><code>jQuery.fn.animateAuto = function(prop, speed, callback){
    var elem, height, width;
    return this.each(function(i, el){
        el = jQuery(el), elem = el.clone().css({"height":"auto","width":"auto"}).appendTo("body");
        height = elem.css("height"),
        width = elem.css("width"),
        elem.remove();

        if(prop === "height")
            el.animate({"height":height}, speed, callback);
        else if(prop === "width")
            el.animate({"width":width}, speed, callback);
        else if(prop === "both")
            el.animate({"width":width,"height":height}, speed, callback);
    });
}</code></pre>
<p>Usage</p>
<pre><code>$(".animateHeight").bind("click", function(e){
    $(".test").animateAuto("height", 1000);
});

$(".animateWidth").bind("click", function(e){
    $(".test").animateAuto("width", 1000);
});

$(".animateBoth").bind("click", function(e){
    $(".test").animateAuto("both", 1000);
});</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/O9dLiyD3630" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/animate-heightwidth-to-auto/</feedburner:origLink></item>
      <item>
         <title>Get an Images Native Width</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/cAM4WLh74GA/</link>
         <description>&lt;p&gt;If you select and image with jQuery and then use &lt;code&gt;.width()&lt;/code&gt;, you'll get the images current width, even if it's been scaled (e.g. max-width: 100%;). You can access the images native width (even if it doesn't have any attributes which declare it) like this:&lt;/p&gt;
&lt;code&gt;// Get on screen image
var screenImage = $("#image");

// Create new offscreen image to test
var theImage = new Image();
theImage.src = screenImage.attr("src");

// Get accurate measurements from that.
var imageWidth = theImage.width;
var &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=14601</guid>
         <pubDate>Sat, 15 Oct 2011 22:46:19 +0000</pubDate>
         <content:encoded><![CDATA[<p>If you select and image with jQuery and then use <code>.width()</code>, you'll get the images current width, even if it's been scaled (e.g. max-width: 100%;). You can access the images native width (even if it doesn't have any attributes which declare it) like this:</p>
<pre><code>// Get on screen image
var screenImage = $("#image");

// Create new offscreen image to test
var theImage = new Image();
theImage.src = screenImage.attr("src");

// Get accurate measurements from that.
var imageWidth = theImage.width;
var imageHeight = theImage.height;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/cAM4WLh74GA" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/get-an-images-native-width/</feedburner:origLink></item>
      <item>
         <title>Append / Prepend Files</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/EGM1GMtfP-M/</link>
         <description>&lt;p&gt;Rather than having to call / include a file you need on every single page, you can have them automatically prepended (top of file) or appended (bottom of file) automatically through your .htaccess file.&lt;/p&gt;
&lt;code&gt;php_value auto_prepend_file "/real/path/to/file/functions.php"
php_value auto_append_file "/real/path/to/file/footer.php"&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=14472</guid>
         <pubDate>Wed, 05 Oct 2011 12:26:04 +0000</pubDate>
         <content:encoded><![CDATA[<p>Rather than having to call / include a file you need on every single page, you can have them automatically prepended (top of file) or appended (bottom of file) automatically through your .htaccess file.</p>
<pre><code>php_value auto_prepend_file "/real/path/to/file/functions.php"
php_value auto_append_file "/real/path/to/file/footer.php"</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/EGM1GMtfP-M" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/append-prepend-files/</feedburner:origLink></item>
      <item>
         <title>Button With Line Breaks</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/qay9SNfy0Us/</link>
         <description>&lt;p&gt;You can use carriage return characters to break the line: &amp;#38;#x00A;&lt;/p&gt;
&lt;code&gt;&amp;#60;input type="button" value="Really&amp;#38;#x00A;Tall&amp;#38;#x00A; Button"&amp;#62;&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=14438</guid>
         <pubDate>Tue, 27 Sep 2011 16:16:08 +0000</pubDate>
         <content:encoded><![CDATA[<p>You can use carriage return characters to break the line: &amp;#x00A;</p>
<pre><code>&lt;input type="button" value="Really&amp;#x00A;Tall&amp;#x00A; Button"&gt;</code></pre>
<input type="button" value="Really&#x00A;Tall&#x00A; Button"><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/qay9SNfy0Us" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/button-with-line-breaks/</feedburner:origLink></item>
      <item>
         <title>Underline Individual Words</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/_HWNiPC-pmA/</link>
         <description>&lt;p&gt;There is no CSS for applying an underline (&lt;code&gt;text-decoration: underline;&lt;/code&gt;) only to individual words in a multiple-word element. The best way would be to wrap each word in a span (not the spaces, just the words) in spans and apply underline to those spans. Here's jQuery to do that to &lt;code&gt;h1&lt;/code&gt; elements.&lt;/p&gt;
&lt;code&gt;$('h1').each(function() {

	var words = $(this).text().split(' ');

	$(this).empty().html(function() {

		for (i = 0; i &amp;#60; words.length; i++) {
			if (i == 0) {
				$(this).append('&amp;#60;span&amp;#62;' + words[i] &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=14317</guid>
         <pubDate>Tue, 13 Sep 2011 20:39:24 +0000</pubDate>
         <content:encoded><![CDATA[<p>There is no CSS for applying an underline (<code>text-decoration: underline;</code>) only to individual words in a multiple-word element. The best way would be to wrap each word in a span (not the spaces, just the words) in spans and apply underline to those spans. Here's jQuery to do that to <code>h1</code> elements.</p>
<pre><code>$('h1').each(function() {

	var words = $(this).text().split(' ');

	$(this).empty().html(function() {

		for (i = 0; i &lt; words.length; i++) {
			if (i == 0) {
				$(this).append('&lt;span&gt;' + words[i] + '&lt;/span&gt;');
			} else {
				$(this).append(' &lt;span&gt;' + words[i] + '&lt;/span&gt;');
			}
		}

	});

});</code></pre>
<p>Then you could do:</p>
<pre><code>h1 span {
  text-decoration: underline;
}</code></pre>
<p>Similar and slightly more robust solution: <a rel="nofollow" target="_blank" href="http://letteringjs.com/">Lettering.js</a></p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/_HWNiPC-pmA" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/jquery/underline-individual-words/</feedburner:origLink></item>
      <item>
         <title>iPhone Calling and Texting Links</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/nERmWoNUz1k/</link>
         <description>&lt;p&gt;This is the calling one (probably more useful if the clickable text is words, as the iPhone auto-detects phone numbers and does this automatically):&lt;/p&gt;
&lt;code&gt;&amp;#60;a href="tel:1-408-555-5555"&amp;#62;1-408-555-5555&amp;#60;/a&amp;#62;&lt;/code&gt;
&lt;p&gt;This is the SMS one, which overrides the default calling behavior:&lt;/p&gt;
&lt;code&gt;&amp;#60;a href="sms:1-408-555-1212"&amp;#62;New SMS Message&amp;#60;/a&amp;#62;&lt;/code&gt;
&lt;p&gt;Not sure what other things these links might work on... Might be a little dangerous as having non-standard links that don't work or bring up errors is kinda bad UX. Best for mobile-only sites. If someone know if this &amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=13630</guid>
         <pubDate>Tue, 16 Aug 2011 20:55:19 +0000</pubDate>
         <content:encoded><![CDATA[<p>This is the calling one (probably more useful if the clickable text is words, as the iPhone auto-detects phone numbers and does this automatically):</p>
<pre><code>&lt;a href="tel:1-408-555-5555"&gt;1-408-555-5555&lt;/a&gt;</code></pre>
<p>This is the SMS one, which overrides the default calling behavior:</p>
<pre><code>&lt;a href="sms:1-408-555-1212"&gt;New SMS Message&lt;/a&gt;</code></pre>
<p>Not sure what other things these links might work on... Might be a little dangerous as having non-standard links that don't work or bring up errors is kinda bad UX. Best for mobile-only sites. If someone know if this works on Android/Blackberry/Other Mobile, comment below.</p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/nERmWoNUz1k" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/iphone-calling-and-texting-links/</feedburner:origLink></item>
      <item>
         <title>HTML5 Article Structure with hNews</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/z8g0_IQx1Pc/</link>
         <description>&lt;code class="lang-html prettyprint"&gt;&amp;#60;article class="hentry"&amp;#62;
  &amp;#60;header&amp;#62;
    &amp;#60;h1 class="entry-title"&amp;#62;But Will It Make You Happy?&amp;#60;/h1&amp;#62;
    &amp;#60;time class="updated" datetime="2010-08-07 11:11:03-0400" pubdate&amp;#62;08-07-2010&amp;#60;/time&amp;#62;
    &amp;#60;p class="byline author vcard"&amp;#62;
        By &amp;#60;span class="fn"&amp;#62;Stephanie Rosenbloom&amp;#60;/span&amp;#62;
    &amp;#60;/p&amp;#62;
  &amp;#60;/header&amp;#62;

  &amp;#60;div class="entry-content"&amp;#62;
      &amp;#60;p&amp;#62;...article text...&amp;#60;/p&amp;#62;
      &amp;#60;p&amp;#62;...article text...&amp;#60;/p&amp;#62;

      &amp;#60;figure&amp;#62;
        &amp;#60;img src="tammy-strobel.jpg" alt="Portrait of Tammy Strobel" /&amp;#62;
        &amp;#60;figcaption&amp;#62;Tammy Strobel in her pared-down, 400sq-ft apt.&amp;#60;/figcaption&amp;#62;
      &amp;#60;/figure&amp;#62;

      &amp;#60;p&amp;#62;...article text...&amp;#60;/p&amp;#62;
      &amp;#60;p&amp;#62;...article text...&amp;#60;/p&amp;#62;

      &amp;#60;aside&amp;#62;
        &amp;#60;h2&amp;#62;Share this Article&amp;#60;/h2&amp;#62;
        &amp;#60;ul&amp;#62;
          &amp;#60;li&amp;#62;Facebook&amp;#60;/li&amp;#62;
          &amp;#60;li&amp;#62;Twitter&amp;#60;/li&amp;#62;
          &amp;#60;li&amp;#62;Etc&amp;#60;/li&amp;#62;
        &amp;#60;/ul&amp;#62;
      &amp;#60;/aside&amp;#62;

      &amp;#60;div class="entry-content-asset"&amp;#62;
        &amp;#60;a href="photo-full.png"&amp;#62;
          &amp;#60;img src="photo.png" alt="The objects Tammy removed from her life after moving" /&amp;#62;
        &amp;#60;/a&amp;#62;
      &amp;#60;/div&amp;#62;

      &amp;#60;p&amp;#62;...article &amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/</guid>
         <pubDate>Tue, 01 Feb 2011 21:40:50 +0000</pubDate>
         <content:encoded><![CDATA[<pre><code class="lang-html prettyprint">&lt;article class="hentry"&gt;
  &lt;header&gt;
    &lt;h1 class="entry-title"&gt;But Will It Make You Happy?&lt;/h1&gt;
    &lt;time class="updated" datetime="2010-08-07 11:11:03-0400" pubdate&gt;08-07-2010&lt;/time&gt;
    &lt;p class="byline author vcard"&gt;
        By &lt;span class="fn"&gt;Stephanie Rosenbloom&lt;/span&gt;
    &lt;/p&gt;
  &lt;/header&gt;

  &lt;div class="entry-content"&gt;
      &lt;p&gt;...article text...&lt;/p&gt;
      &lt;p&gt;...article text...&lt;/p&gt;

      &lt;figure&gt;
        &lt;img src="tammy-strobel.jpg" alt="Portrait of Tammy Strobel" /&gt;
        &lt;figcaption&gt;Tammy Strobel in her pared-down, 400sq-ft apt.&lt;/figcaption&gt;
      &lt;/figure&gt;

      &lt;p&gt;...article text...&lt;/p&gt;
      &lt;p&gt;...article text...&lt;/p&gt;

      &lt;aside&gt;
        &lt;h2&gt;Share this Article&lt;/h2&gt;
        &lt;ul&gt;
          &lt;li&gt;Facebook&lt;/li&gt;
          &lt;li&gt;Twitter&lt;/li&gt;
          &lt;li&gt;Etc&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/aside&gt;

      &lt;div class="entry-content-asset"&gt;
        &lt;a href="photo-full.png"&gt;
          &lt;img src="photo.png" alt="The objects Tammy removed from her life after moving" /&gt;
        &lt;/a&gt;
      &lt;/div&gt;

      &lt;p&gt;...article text...&lt;/p&gt;
      &lt;p&gt;...article text...&lt;/p&gt;

      &lt;a class="entry-unrelated" href="http://fake.site/"&gt;Find Great Vacations&lt;/a&gt;
  &lt;/div&gt;

  &lt;footer&gt;
    &lt;p&gt;
      A version of this article appeared in print on August 8,
      2010, on page BU1 of the New York edition.
    &lt;/p&gt;
    &lt;div class="source-org vcard copyright"&gt;
        Copyright 2010 &lt;span class="org fn"&gt;The New York Times Company&lt;/span&gt;
    &lt;/div&gt;
  &lt;/footer&gt;
&lt;/article&gt;</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/z8g0_IQx1Pc" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/html/html5-article-structure-with-hnews/</feedburner:origLink></item>
      <item>
         <title>Subdirectories URL Internally Redirect to Query String</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/cZYOG4YoyI8/</link>
         <description>&lt;p&gt;&lt;strong&gt;The URL in the browser would be:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;http://css-tricks.com/index.php/teachers/a/&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The actual page rendered by the server would be:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;http://css-tricks.com/index.php?search=teachers&amp;#038;sort=a&lt;/p&gt;
&lt;code class="htaccess"&gt;RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&amp;#38;sort=$2 [NC]&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/</guid>
         <pubDate>Fri, 06 Aug 2010 03:17:13 +0000</pubDate>
         <content:encoded><![CDATA[<p><strong>The URL in the browser would be:</strong></p>
<p>http://css-tricks.com/index.php/teachers/a/</p>
<p><strong>The actual page rendered by the server would be:</strong></p>
<p>http://css-tricks.com/index.php?search=teachers&#038;sort=a</p>
<pre><code class="htaccess">RewriteEngine on
RewriteRule ^index/([^/]+)/([^/]+).php /page.php?search=$1&amp;sort=$2 [NC]</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/cZYOG4YoyI8" height="1" width="1"/>]]></content:encoded>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/subdirectories-redirect-query-string/</feedburner:origLink></item>
      <item>
         <title>PHP Error Logging</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/zvqsuL3j1Xw/</link>
         <description>&lt;p&gt;Log errors to a file, and prevent showing them to the user. Make sure that the file exists and youre able to write to it.&lt;/p&gt;
&lt;code class="htaccess"&gt;# display no errs to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# log to file
php_flag log_errors on
php_value error_log /location/to/php_error.log&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=6589</guid>
         <pubDate>Mon, 14 Jun 2010 00:29:45 +0000</pubDate>
         <content:encoded><![CDATA[<p>Log errors to a file, and prevent showing them to the user. Make sure that the file exists and youre able to write to it.</p>
<pre><code class="htaccess"># display no errs to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
# log to file
php_flag log_errors on
php_value error_log /location/to/php_error.log</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/zvqsuL3j1Xw" height="1" width="1"/>]]></content:encoded>
         <category>Article</category>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/php-error-logging/</feedburner:origLink></item>
      <item>
         <title>iPad Detection</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/0cAiaFMmUm4/</link>
         <description>&lt;p&gt;Of course, the iPad is a pretty large screen and a fully capable browser, so most websites don't need to have iPad specific versions of them. But if you need to, you can detect for it with .htaccess&lt;/p&gt;
&lt;code class="htaccess"&gt;RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]&lt;/code&gt;
&lt;p&gt;This will redirect iPad users to a URL you specify. This is probably the best way to do it (assuming you are running an Apache server), but if you aren't, there are &lt;a rel="nofollow" target="_blank" href="http://davidwalsh.name/detect-ipad"&gt;PHP and JavaScript &lt;/a&gt;&amp;#8230;&lt;/p&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=6256</guid>
         <pubDate>Fri, 23 Apr 2010 19:22:48 +0000</pubDate>
         <content:encoded><![CDATA[<p>Of course, the iPad is a pretty large screen and a fully capable browser, so most websites don't need to have iPad specific versions of them. But if you need to, you can detect for it with .htaccess</p>
<pre><code class="htaccess">RewriteCond %{HTTP_USER_AGENT} ^.*iPad.*$
RewriteRule ^(.*)$ http://ipad.yourdomain.com [R=301]</code></pre>
<p>This will redirect iPad users to a URL you specify. This is probably the best way to do it (assuming you are running an Apache server), but if you aren't, there are <a rel="nofollow" target="_blank" href="http://davidwalsh.name/detect-ipad">PHP and JavaScript methods here</a>. </p><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/0cAiaFMmUm4" height="1" width="1"/>]]></content:encoded>
         <category>Article</category>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/ipad-detection/</feedburner:origLink></item>
      <item>
         <title>Force Correct content-type for XHTML Documents</title>
         <link>http://feedproxy.google.com/~r/CSS-TricksSnippets/~3/0vGap980cBY/</link>
         <description>&lt;p&gt;Most webservers serve XHTML content as text/html what is definitly the right way to handle XHTML documents. In case the server isn't doing that correctly, you can force it on Apache servers with .htaccess:&lt;/p&gt;
&lt;code class="htaccess"&gt;RewriteEngine On
RewriteCond %{HTTP_ACCEPT} application/xhtml&amp;#92;+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml&amp;#92;+xml&amp;#92;s*;&amp;#92;s*q=0
RewriteCond %{REQUEST_URI} &amp;#92;.html$
RewriteCond %{THE_REQUEST} HTTP/1&amp;#92;.1
RewriteRule .* - "[T=application/xhtml+xml; charset=ISO-8859-1]"&amp;#8230;&lt;/code&gt;</description>
         <guid isPermaLink="false">http://css-tricks.com/?page_id=6140</guid>
         <pubDate>Wed, 07 Apr 2010 18:17:00 +0000</pubDate>
         <content:encoded><![CDATA[<p>Most webservers serve XHTML content as <tt>text/html</tt> what is definitly the right way to handle XHTML documents. In case the server isn't doing that correctly, you can force it on Apache servers with .htaccess:</p>
<pre><code class="htaccess">RewriteEngine On
RewriteCond %{HTTP_ACCEPT} application/xhtml&#92;+xml
RewriteCond %{HTTP_ACCEPT} !application/xhtml&#92;+xml&#92;s*;&#92;s*q=0
RewriteCond %{REQUEST_URI} &#92;.html$
RewriteCond %{THE_REQUEST} HTTP/1&#92;.1
RewriteRule .* - "[T=application/xhtml+xml; charset=ISO-8859-1]"</code></pre><img src="http://feeds.feedburner.com/~r/CSS-TricksSnippets/~4/0vGap980cBY" height="1" width="1"/>]]></content:encoded>
         <category>Article</category>
      <feedburner:origLink>http://css-tricks.com/snippets/htaccess/force-correct-content-type-for-xhtml-documents/</feedburner:origLink></item>
   </channel>
</rss><!-- fe5.pipes.sp1.yahoo.com compressed/chunked Sun May 27 00:47:04 UTC 2012 -->

