<?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"?><!-- generator="wordpress/2.3.3" --><rss 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/" version="2.0">

<channel>
	<title>Perishable Press</title>
	<link>http://perishablepress.com/press</link>
	<description>Digital Design &amp; Dialogue ~</description>
	<pubDate>Thu, 12 Nov 2009 01:34:03 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /><meta xmlns="http://pipes.yahoo.com" name="pipes" content="noprocess" /><image><link>http://perishablepress.com/</link><url>http://perishablepress.com/link/perishablepress.jpeg</url><title>Perishable Press</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://perishablepress.com/press/feed/" type="application/rss+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">perishablepress</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://perishablepress.com/press/feed/" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://my.feedlounge.com/external/subscribe?url=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://static.feedlounge.com/buttons/subscribe_0.gif">Subscribe with FeedLounge</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.live.com/?add=http%3A%2F%2Fperishablepress.com%2Fpress%2Ffeed%2F" src="http://tkfiles.storage.msn.com/x1piYkpqHC_35nIp1gLE68-wvzLZO8iXl_JMledmJQXP-XTBOLfmQv4zhj4MhcWEJh_GtoBIiAl1Mjh-ndp9k47If7hTaFno0mxW9_i3p_5qQw">Subscribe with Live.com</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>It’s Here: Digging into WordPress!</title>
		<link>http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/</link>
		<comments>http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:46:57 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[books]]></category>

		<category><![CDATA[DiW]]></category>

		<category><![CDATA[news]]></category>

		<category><![CDATA[publishing]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/</guid>
		<description><![CDATA[										 After nearly a year of production, Chris Coyier and I are stoked to announce our new book: Digging into WordPress! It&#8217;s nine jam-packed chapters (400 pages!) stuffed with everything you need to take your WordPress skills to the next level and really get the most out of WordPress. We take you through everything &#8212; [...]]]></description>
			<content:encoded><![CDATA[										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-1.png" alt="[ Digging into WordPress ]" /> After nearly a year of production, Chris Coyier and I are stoked to announce our new book: <a href="http://digwp.com/book/" title="Get 'em while their hot!">Digging into WordPress</a>! It&rsquo;s nine jam-packed chapters (400 pages!) stuffed with everything you need to take your WordPress skills to the <em>next level</em> and really get the <em>most</em> out of WordPress. We take you through everything &#8212; from setting up for success and creating the perfect theme to optimizing performance and tightening security, Digging into WordPress <a href="http://digwp.com/book/testimonials/" title="Read what others are saying about Digging into WordPress">delivers the goods</a>. You&rsquo;ll learn how to harness the full potential of WordPress with all of the tips, tricks, and code you need to make it happen.</p>
										<h3>Special 10-Day Discount</h3>
										<p>For the next ten days, use coupon code <em>DIWPERISHABLE</em> to <strong>save $5 instantly</strong>. The book sells for $27, so with the coupon code you can grab it for a cool 22 bucks. This is a limited-time deal so take <em>advantage</em> and hook it up <em>now</em>. <a href="http://digwp.com/book/" title="Learn more / buy book">Go here to get the scoop and download the book</a>.</p>
										<h3>Living, Breathing PDF Format..</h3>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-4.png" alt="[ Learn WordPress Now ]" /> The <acronym title="Portable Document Format">PDF</acronym> version of the book is awesome because we will be able to update and expand it indefinitely. As WordPress changes, the book will evolve with new information, techniques, and code. This is why we call the <acronym title="Digging into WordPress">DiW</acronym> <acronym title="Portable Document Format">PDF</acronym> a &ldquo;living, breathing document&rdquo; &#8212; it will <em>grow</em> with WordPress, and will be updated and improved periodically well into the future.</p>
										<h3>..and a Printed Version Coming Soon</h3>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-2.png" alt="[ *Really* Learn It. ]" /> In addition to the <acronym title="Portable Document Format">PDF</acronym>, a printed version of Digging into WordPress will also be available sometime in the near future. Everyone who purchases the <acronym title="Portable Document Format">PDF</acronym> version of the book will receive a fair discount on the printed book when it&rsquo;s released. The printed book will be awesome, but the <acronym title="Portable Document Format">PDF</acronym> is ideal because it&rsquo;s easy to search, easy to zoom, easy to transport, and easy to copy &amp; paste code. It even features actual hyperlinks that make it easy to jump to linked resources (and there&rsquo;s a <em>zillion</em> of &lsquo;em!).</p>
										<h3>Lifetime Subscription</h3>
										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/DIW-125-3.png" alt="[ Take Your WordPress Skills to the Next Level ]" /> All <acronym title="Digging into WordPress">DiW</acronym> customers automatically get a lifetime subscription to all future updates and new versions of the book. Chris and I are <a href="http://digwp.com/" title="Digging into WordPress">crazy about WordPress</a> and plan on sharing our experience as time goes on. There are a few other WordPress books out there, but this one won&rsquo;t get old and outdated as WordPress evolves. Whenever we update the book and release a new version, we&rsquo;ll send you a link for a free download &#8212; <em>fresh</em> WordPress with the <em>click</em> of a button.</p>
										<h3>Affiliate Program</h3>
										<p>To help promote the book, we are also providing an <a href="http://digwp.com/book/affiliate/" title="DiW Affiliate Program">affiliate program</a>. If you like the book and want to help sell it, you can earn money doing so. For the <acronym title="Portable Document Format">PDF</acronym> version of the book, we avoid the substantial costs typically involved with the printing, handling and shipping of a physical product. <strong>So, we are offering an affiliate commission of 50% for all affiliate sales.</strong> You are doing the legwork, and we appreciate it. <a href="http://digwp.com/book/affiliate/" title="DiW Affiliate Program">Learn more here</a>.</p>
										<h3>Thank You</h3>
										<p><strong>Thanks in advance</strong> to anybody who picks up a copy. It goes a long way toward helping both Chris and I create all the <a href="http://css-tricks.com/" title="CSS-Tricks">other</a> <a href="http://perishablepress.com/" title="Perishable Press">free</a> <a href="http://digwp.com/" title="Digging into WordPress">content</a> we love to share.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/digging-into-wordpress_01.jpg" alt="[ Digging into WordPress ]" /><br /><small><a style="border: 0 none;" href="http://digwp.com/book/" title="Get the most out of WordPress!">Digging into WordPress &#8212; packed with yummy WordPress goodness!</a></small></p>
										<h3>Sneak peak..</h3>
										<p>You can <a href="http://digwp.com/book-demo/Digging-Into-WP-DEMO.pdf" title="Download DiW Demo PDF">download a demo of the book here</a>. The demo features the Table of Contents and part of Chapter 3. Here&rsquo;s a little collage showing the general look and feel of what&rsquo;s inside the book..</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/digging-wp/digging-into-wordpress_00.jpg" alt="[ DiW Sneak Peak ]" /><br /><small><a style="border: 0 none;" href="http://digwp.com/book/" title="Take your WordPress Skills to the Next Level">Digging into WordPress &#8212; 9 Chapters, 400 Pages, and <em>tons</em> of great tips, tricks, and code</a></small></p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/" title="Read 'It&#8217;s Here: Digging into WordPress!' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2009/06/16/digging-into-wordpress/" title="Digging Into WordPress (June 16, 2009)">Digging Into WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2009/02/15/book-review-wordpress-for-business-bloggers/" title="Book Review: WordPress for Business Bloggers (February 15, 2009)">Book Review: WordPress for Business Bloggers</a></li>
					<li><a href="http://perishablepress.com/press/2009/04/15/looking-for-a-publisher/" title="Looking for a Publisher (April 15, 2009)">Looking for a Publisher</a></li>
					<li><a href="http://perishablepress.com/press/2006/11/12/perishable-press-upgrade-to-wordpress-205/" title="Perishable Press Upgrade to WordPress 2.0.5 (November 12, 2006)">Perishable Press Upgrade to WordPress 2.0.5</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/22/wordpress-21-released/" title="WordPress 2.1 Released (January 22, 2007)">WordPress 2.1 Released</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/21/rocking-the-boat/" title="Rocking the Boat (October 21, 2007)">Rocking the Boat</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/05/site-overhaul-phase-two-switching-default-theme/" title="Site Overhaul, Phase Two: Switching Default Theme (November 5, 2007)">Site Overhaul, Phase Two: Switching Default Theme</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:NHM--yOz8lg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:NHM--yOz8lg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:NHM--yOz8lg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=4QEFGpwQ8e0:NHM--yOz8lg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=4QEFGpwQ8e0:NHM--yOz8lg:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/11/11/its-here-digging-into-wordpress/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Perfect &lt;pre&gt; Tags</title>
		<link>http://perishablepress.com/press/2009/11/09/perfect-pre-tags/</link>
		<comments>http://perishablepress.com/press/2009/11/09/perfect-pre-tags/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 16:15:36 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[Structure]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[elements]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[tags]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/11/09/perfect-pre-tags/</guid>
		<description><![CDATA[										If you operate a website that features lots of code examples, you know how important it is to spend some quality time styling the &#60;pre&#62; element. When left unstyled, wild &#60;pre&#62; tags will mangle your preformatted content and destroy your site&#8217;s layout. Different browsers treat the &#60;pre&#62; tag quite differently, varying greatly in their default [...]]]></description>
			<content:encoded><![CDATA[										<p>If you operate a website that features lots of code examples, you know how important it is to spend some quality time styling the <code>&lt;pre&gt;</code> element. When left unstyled, wild <code>&lt;pre&gt;</code> tags will mangle your preformatted content and destroy your site&rsquo;s layout. Different browsers treat the <code>&lt;pre&gt;</code> tag quite differently, varying greatly in their default handling of font-sizing, scrollbar-rendering, and word-wrapping. Indeed, getting your preformatted code to look consistent, usable, and stylish across browsers is no easy task, but it certainly can be done. In this article, I&rsquo;ll show you everything you need to create perfect <code>&lt;pre&gt;</code> tags.</p>
										<h3>First thangs first</h3>
										<p>Before getting into it, let&rsquo;s take a moment to ensure we&rsquo;re all on the same page. The <acronym title="(eXtensible) Hypertext Markup Language">(X)HTML</acronym> <code>&lt;pre&gt;</code> element is used to display preformatted text, code, or just about anything else. <code>pre</code> tags are ideal for multiple lines of code or text that need to retain character spacing, display unformatted characters, keep inherent line breaks, and so on. </p>
										<p>Let&rsquo;s say we have the following code that we want to include in a web page:</p>
										<pre><code>&lt;?php function shortLink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" =&gt; 'http://' // default URL
	), $atts));
	return '&lt;a href="'.$href.'"&gt;'.$content.'&lt;/a&gt;';
}
add_shortcode('link', 'shortLink'); ?&gt;</code></pre>
										<p>After converting the &ldquo;<code>&lt;</code>&rdquo; characters to their encoded equivalents, &ldquo;<code>&amp;lt;</code>&rdquo;, we would wrap the code in <code>&lt;pre&gt;</code> tags and get this in the browser:</p>
										<pre><code>&lt;?php function shortLink($atts, $content = null) {
	extract(shortcode_atts(array(
		"href" =&gt; 'http://' // default URL
	), $atts));
	return '&lt;a href="'.$href.'"&gt;'.$content.'&lt;/a&gt;';
}
add_shortcode('link', 'shortLink'); ?&gt;</code></pre>
										<p>Looks pretty similar, eh? Notice that the line breaks, spacing, and unencoded characters (besides opening brackets) That&rsquo;s the whole point: the <code>&lt;pre&gt;</code> tag enables you to easily display raw chunks of source code, text (think poetry), and any other content that we don&rsquo;t want the browser to process. Now let&rsquo;s look at that same code when displayed <em>without</em> <code>&lt;pre&gt;</code> tags:</p>
										<p><?php function shortLink($atts, $content = null) {<br />
	extract(shortcode_atts(array(<br />
		"href" => &#8216;http://&#8217; // default URL<br />
	), $atts));<br />
	return &#8216;<a href="#">&#8216;.$content.&#8217;</a>&#8216;;<br />
}<br />
add_shortcode(&#8217;link&#8217;, &#8217;shortLink&#8217;); ?></p>
										<p>As you can see, when not wrapped in <code>&lt;pre&gt;</code> tags, code examples such as this are inaccurate and essentially useless. <code>&lt;pre&gt;</code> elements ensure that the content retains its &ldquo;natural&rdquo; format, which is crucial for displaying code, poetry, equations, and other types of specialized content.</p>
										<p>Also, note that the <code>&lt;code&gt;</code> element is frequently used in conjunction with the <code>&lt;pre&gt;</code> tag when using syntax highlighters and formatting plugins such as the excellent <a href="http://priyadi.net/archives/2005/09/27/wordpress-plugin-code-autoescape/" title="Code Auto Escape">Code Auto Escape</a>. For example, here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, all multi-line code examples are wrapped with <code>&lt;pre&gt;&lt;code&gt;</code> and then auto-escaped using the Auto Escape plugin, which automatically escapes <em>all</em> characters within <code>&lt;pre&gt;</code> elements, eliminating the need to manually convert, say, opening brackets to their encoded equivalents. Many other syntax highlighters and code-formatting plugins also provide this functionality, greatly facilitating the post-writing process. Such tools help you streamline production and improve display of your preformatted content.</p>
										<p>One last thing about the <code>&lt;pre&gt;</code> tag before we dive into the good stuff. You should keep in mind that <code>&lt;pre&gt;</code> tags are used for displaying <strong>blocks</strong> of preformatted characters. That is, regardless of how many lines of text or code you use, the <code>&lt;pre&gt;</code> tag is a block-level element and will display its content as such. Conversely, the <code>&lt;code&gt;</code> tag is an <strong>inline</strong> element that is perfect for displaying individual words, characters, and lines of preformatted text <em>within</em> a block-level element. For example, I use the <code>&lt;code&gt;</code> tag all the time &#8212; just check out the source code of the previous couple of sentences to see what I mean.</p>
										<h3>Displaying preformatted content &amp; dealing with overflow</h3>
										<h4>Default behavior: horizontal scrollbars</h4>
										<p>One of the biggest challenges to displaying preformatted content using the <code>&lt;pre&gt;</code> tag is dealing with continuous strings of characters such as <acronym title="Uniform Resource Locator">URL</acronym>s and long chunks of code. By default, the <code>&lt;pre&gt;</code> element handles this by stretching to fit its content. Assuming that no widths have been specified in the <acronym title="Cascading Style Sheets">CSS</acronym>, the <code>&lt;pre&gt;</code> element will expand in length to accomodate its longest line of content. Interesting, but not very practical in most design scenarios. As soon as a constraining width is applied, the <code>&lt;pre&gt;</code> element uses a horizontal scrollbar to accomodate any content that doesn&rsquo;t &ldquo;fit&rdquo; within the display area. This default behavior is deployed in the stylesheet like this:</p>
										<pre><code>pre {
	overflow: auto;
	width: 500px;
	}</code></pre>
										<p>This is a commonly seen way of dealing with oversized <code>&lt;pre&gt;</code> content. It&rsquo;s fast, easy, and effective. Even so, not everyone likes to scroll..</p>
										<h4>Word-wrapping</h4>
										<p>Instead of using a scrollbar to display long lines of preformatted text, some prefer to wrap the content within the display area of the <code>&lt;pre&gt;</code> element. When we wrap preformatted content, any lines that extend beyond the specified width will wrap to the next line. As simple as this sounds, some browsers have real problems when it comes to continuous strings of text such as long <acronym title="Uniform Resource Locator">URL</acronym>s. Many browsers are unable to break up continuous lines of text unless specifically instructed to do so. Fortunately this is possible using a crefully crafted set of <acronym title="Cascading Style Sheets">CSS</acronym> directives.</p>
										<p>To enable word-wrapping for your <code>&lt;pre&gt;</code> content, use the following slice of <acronym title="Cascading Style Sheets">CSS</acronym> and edit the first directive to set the desired width:</p>
										<pre><code>pre {
	width: 500px;                          /* specify width  */
	white-space: pre-wrap;                 /* CSS3 browsers  */
	white-space: -moz-pre-wrap !important; /* 1999+ Mozilla  */
	white-space: -pre-wrap;                /* Opera 4 thru 6 */
	white-space: -o-pre-wrap;              /* Opera 7 and up */
	word-wrap: break-word;                 /* IE 5.5+ and up */
	/* overflow-x: auto; */                /* Firefox 2 only */
	/* width: 99%; */		       /* only if needed */
	}</code></pre>
										<p>Once in place, this code will force your <code>&lt;pre&gt;</code> areas to stay at 500 pixels wide. If any continuous lines extend beyond this width, they will be broken and wrapped accordingly.</p>
										<h4>Auto-expanding code box with CSS</h4>
										<p>If word-wrapping isn&rsquo;t for you, you may want to implement some auto-expansion functionality. Using a small snippet of <acronym title="Cascading Style Sheets">CSS</acronym>, it is possible to style your <code>&lt;pre&gt;</code> tags such that they magically expand whenever the user hovers their mouse. So, for example, your <code>&lt;pre&gt;</code> areas would display normally at 500pixels in width, but as soon as the user hovers their cursor over the area, it would instantly expand to a larger width, say, 700 pixels.</p>
										<p>Setting this up is easy. Just include the following <acronym title="Cascading Style Sheets">CSS</acronym> in your stylesheet and enjoy the results:</p>
										<pre><code>pre {
	overflow: auto;
	width: 500px;
	}
pre:hover {
	position: relative;
	width: 700px;
	z-index: 99;
	}</code></pre>
										<p>Of course, you will want edit the <code>width</code> values according to your needs and customize your <code>&lt;pre&gt;</code> and hover styles to look all sweet. You know.</p>
										<p>There are some pros and cons to this method. Here are some of the pros:</p>
										<ul>
										<li>It works great without requiring any JavaScript.</li>
										<li>Scrollbars appear only when the box is not expanded.</li>
										<li>The boxes expand instantly &#8212; no waiting required.</li>
										<li>Works fine even without an inner <code>&lt;code&gt;</code> wrapper.</li>
										</ul>
										<p>..and of course some of the cons:</p>
										<ul>
										<li>All <code>&lt;pre&gt;</code> tags expand even if it&rsquo;s not necessary (i.e., the code fits)</li>
										<li>The sudden display change may disorient/confuse newer web users.</li>
										<li>Expanding box may interfere with other page elements.</li>
										<li>Even after expansion, the <code>&lt;pre&gt;</code> are may still require horizontal scrollbars to see all of the content.</li>
										</ul>
										<h4>Auto-expanding code box with jQuery et al</h4>
										<p>The <acronym title="Cascading Style Sheets">CSS</acronym> expanding-box method works nice, but it&rsquo;s a bit choppy &#8212; upon hover, it&rsquo;s like, BAM &#8212; suddenly you&rsquo;re staring at a full-size code box. Using a little bit of jQuery, we can create a much smoother <a href="http://digwp.com/2009/07/making-an-expanding-code-box/" title="Making an Expanding Code Box">expanding code box</a>, as originally shared by Chris Coyier at <a href="http://digwp.com/" title="Get the most out of WordPress!">Digging into WordPress</a>.</p>
										<p>The jQuery method is an improvement over the <acronym title="Cascading Style Sheets">CSS</acronym> method, behaving more elegantly:</p>
										<ul>
										<li>Expands only when hovered over</li>
										<li>Expands only as wide as necessary</li>
										<li>Expands with some nice animation</li>
										</ul>
										<p>To implement, begin by styling the <code>&lt;pre&gt;</code> element with a little <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>pre {
	overflow: auto;
	width: 500px; 
	}</code></pre>
										<p>This will prepare the <code>&lt;pre&gt;</code> element for the following JavaScript:</p>
										<pre><code>$(function(){
	$("pre").hover(function() {
		var codeInnerWidth = $("code", this).width() + 10;
		if (codeInnerWidth &gt; 500) {
			$(this).stop(true, false).css({zIndex:"99",position:"relative",overflow:"hidden"}).animate({width:codeInnerWidth+"px"});
		}
	}, function() {
		$(this).stop(true, false).animate({width:500});
	});
});</code></pre>
										<p>And that&rsquo;s pretty much it. You&rsquo;ll want to customize the <acronym title="Cascading Style Sheets">CSS</acronym> and jQuery to fit your needs, but the main thing is getting all of the widths to match up (both in the <acronym title="Cascading Style Sheets">CSS</acronym> and JavaScript). When JavaScript is unavailable on the user&rsquo;s browser, this method degrades gracefully to default <code>&lt;pre&gt;</code> elements with auto-scrollbars.</p>
										<p>As discussed at Digging into WordPress, this method requires that your preformatted content is wrapped in both <code>&lt;pre&gt;</code> and <code>&lt;code&gt;</code> tags. For complete information, check out the <a href="http://digwp.com/2009/07/making-an-expanding-code-box/" title="Making an Expanding Code Box">the original article</a>.</p>
										<h3>Whipping scrollbars into shape</h3>
										<h4>Vertical scrollbars, height, and Internet Explorer</h4>
										<p>If you do decide to use scrollbars to display overflow content, you will discover many inconsistencies across browsers, especially (surprise surprise) Internet Exploder. The first thing to understand is that, on standards-compliant browsers (i.e., anything other than IE) <strong>vertical</strong> scrollbars will only appear if an explicit <code>height</code> is specified for the <code>&lt;pre&gt;</code> element. If it is, vertical scrollbars will appear whenever the preformatted content contains more lines than is viewable within the specified height.</p>
										<p>Why is this important? Because it makes eliminating vertical scrollbars rather easy. As a general rule of thumb, I never specify heights for preformatted content, but there are situations where you might want to do so. </p>
										<p>As for our &lsquo;ol friend <acronym title="Internet Explorer">IE</acronym>, you are pretty much going to get vertical scrollbars regardless of whether or not you declare a height. They just appear on their own. Like friends of that squatter you mistakenly let stay with you for awhile.</p>
										<p>Fortunately, there are effective ways to exterminate those stinky vertical scrollbars in <acronym title="Internet Explorer">IE</acronym>. Here is the method I use on many of my sites:</p>
										<pre><code>/* no vertical scrollbars for standards-compliant browsers */
pre {
	overflow: auto; 
	width: 500px;
	}
/* no vertical scrollbars for IE 7 */
*:first-child+html pre {
	padding-bottom: 20px;
	overflow-y: hidden;
	overflow: visible;
	overflow-x: auto; 
	}
/* no vertical scrollbars for IE 6 */
* html pre { 
	padding-bottom: 20px;
	overflow: visible;
	overflow-x: auto;
	}</code></pre>
										<p>That code is pretty much plug-n-play with only the essentials, but you will want to customize the <code>width</code> in the first declaration block and add other styles as desired. What&rsquo;s happening with this code? Glad you axed. Lemme break it down:</p>
										<ol>
										<li><strong>first block</strong> &#8212; sets default scrolling for standards-compliant browsers; no vertical scrollbars unless explicit <code>height</code> is set.</li>
										<li><strong>second block</strong> &#8212; hack for IE 7 that removes the vertical scrollbar and adds a bit of padding to make room for any <em>horizontal</em> scrollbar that might be present.</li>
										<li><strong>third block</strong> &#8212; hack for IE 6 that removes the vertical scrollbar and also adds some padding.</li>
										</ol>
										<p>Of course, rather than using unsightly <acronym title="Cascading Style Sheets">CSS</acronym> hacks for <acronym title="Internet Explorer">IE</acronym>, it&rsquo;s best practice to summon them via <a href="http://perishablepress.com/press/2007/07/18/wrapping-your-head-around-downlevel-conditional-comments/" title="Wrapping Your Head around Downlevel Conditional Comments">conditional comments</a>. Once in place, this code will neutralize and eliminate those nasty vertical scrollbars in <acronym title="Internet Explorer">IE</acronym> and provide some extra bottom-padding to make room for horizontal scrollbars when they appear. This code is effective, but the additional padding is not needed when the content fits within the <code>&lt;pre&gt;</code> area and the horizontal scrollbar does not appear, resulting in an awkward blank line. Fortunately we can turn to JavaScript to account for this dynamic display property.</p>
										<h4>Fixing IE&rsquo;s funky inside scrollbars with JavaScript</h4>
										<p>&ldquo;<acronym title="Internet Explorer">IE</acronym> is <em>so</em> bad..&rdquo; &#8212; <em>how</em> bad is it? It renders horizontal <code>&lt;pre&gt;</code> scrollbars on the <strong>inside</strong> of the element. This sucks because it interferes with content, pushes everything up about 20 pixels, and invokes display of the unnecessary vertical scrollbar.</p>
										<p>We saw how to remedy this display deficiency using <acronym title="Cascading Style Sheets">CSS</acronym> in the previous section, but it wasn&rsquo;t quite ideal because of the extra bottom padding that is used to ensure content display when horizontal scrollbars appear. A better way to handle it is to use a little JavaScript to do the following:</p>
										<ol>
										<li>Check if the browser is Internet Explorer</li>
										<li>Find all <code>&lt;pre&gt;</code> elements with overflowing horizontal content</li>
										<li>Add 20 pixels of bottom padding to account for the horizontal scrollbar</li>
										<li>Remove the vertical scrollbar</li>
										</ol>
										<p>Thankfully, <a href="http://remysharp.com/2008/01/21/fixing-ie-overflow-problem/" title="Fixing IE overflow problem">Remy Sharp</a> delivers this functionality with the following slice of JavaScript:</p>
										<pre><code>window.onload = function () {  
	// only apply to IE  
	if (!/*@cc_on!@*/0) return;  
	// find every element to test  
	var all = document.getElementsByTagName('*'), i = all.length;  
	// fast reverse loop  
	while (i--) {    
		// if the scrollWidth (the real width) is greater than 
		// the visible width, then apply style changes    
		if (all[i].scrollWidth &gt; all[i].offsetWidth) {
			all[i].style['paddingBottom'] = '20px';
			all[i].style['overflowY'] = 'hidden';
		}
	}
};</code></pre>
										<p>..and as if that weren&rsquo;t cool enough, here&rsquo;s the same functionality via jQuery:</p>
										<pre><code>(function ($) {
	$.fn.fixOverflow = function () {
		if ($.browser.msie) {
			return this.each(function () {
				if (this.scrollWidth &gt; this.offsetWidth) {
					$(this).css({ 'padding-bottom' : '20px', 'overflow-y' : 'hidden' });
				}
			});
		} else {
			return this;
		}
	};
})(jQuery);
// usage
$('pre').fixOverflow().doOtherPlugin();</code></pre>
										<p>Either of these methods will do the job nicely, making <acronym title="Internet Explorer">IE</acronym> appear to display any horizontal scrollbars on the <em>outside</em> of the <code>&lt;pre&gt;</code> element.</p>
										<p>Interestingly enough, we can also execute this dynamic functionality from within the stylesheet and eliminate the need for any JavaScript. By using one of <acronym title="Internet Explorer">IE</acronym>&rsquo;s proprietary <code>expression</code> properties, we can include the following directly in our <acronym title="Internet Explorer">IE</acronym>-only stylesheet:</p>
										<pre><code>pre {
	width: 500px;
	overflow-x: auto;
	overflow-y: hidden;
	padding-bottom: expression(this.scrollWidth &gt; this.offsetWidth ? 20 : 0);
	}</code></pre>
										<p>Just specify the width and you&rsquo;re off to the races. For either of these dynamic methods (i.e., JavaScript, jQuery, or CSS expression), keep in mind that we are treating <em>horizontal</em> overflow issues when an explicit vertical height has not been specified.</p>
										<h3>Bonus tip: displaying a name for each class of <code>&lt;pre&gt;</code> text</h3>
										<p>If you have different types of preformatted content, you can output the name of each one within the content itself. To illustrate, let&rsquo;s say you provide different types of code snippets at your site, such as <acronym title="Cascading Style Sheets">CSS</acronym>, <acronym title="Hypertext Markup Language">HTML</acronym>, and <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>. By adding a class to an inner <code>&lt;code&gt;</code> element, you can combine <acronym title="Cascading Style Sheets">CSS</acronym>-2.1&rsquo;s attribute selector and <code>:after</code> pseudo-element selector to display the class name within the preformatted content area.</p>
										<pre><code>pre code[class]:after {
  content: 'highlight: ' attr(class);
  display: block; text-align: right;
  font-size: smaller;
  padding-top: 5px;
}</code></pre>
										<p>Then, you set up your preformatted code like so:</p>
										<pre><code>&lt;pre&gt;&lt;code class="CSS"&gt;</code></pre>
										<p>The class name you specify for each type of code block will then be displayed to the bottom-right of the preformatted content area. Shouts out to <a href="http://css-tricks.com/">Chris Coyier</a> for this awesome trick.</p>
										<h3>Styling preformatted content</h3>
										<p>Now that we know how to improve the physical properties of the <code>&lt;pre&gt;</code> element, let&rsquo;s wrap things up with a few ideas for styling the actual preformatted content.</p>
										<h4>Fonts</h4>
										<p>When styling your preformatted content, employ fonts suitable to its purpose. For example, if your site is mostly sporting code snippets, throw down with some tough monospace typography:</p>
										<ul>
										<li><code>monospace</code></li>
										<li><code>"Courier new", Courier, "Andale Mono", monospace</code></li>
										<li><code>Consolas, "Lucida Console", Monaco, monospace</code></li>
										<li><code>Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace</code></li>
										</ul>
										<p>To create the perfect monospace font stack, you really should be testing on as many different browsers as possible. Check different operating systems, browsers, zoom settings, and types of preformatted content. A couple of notes: <em>Courier</em> is an incredibly tight-looking font that, unfortunately, does not scale well on all browsers/systems. Particularly, there seems to be a lower-limit to the display size of the Courier font. Also, to get things looking right on both PC and Mac without all the fuss, simply declare &ldquo;<code>monospace</code>&rdquo; for your <code>&lt;pre&gt;</code> font and you&rsquo;ll get a great-looking font on both systems.</p>
										<h4>Borders</h4>
										<p>While maybe not beneficial to <em>every</em> block of preformatted text, a nice set of borders can really help accent and emphasize your content. Especially for code snippets, adding a border around the area can help users discern easily between it and the post content.</p>
										<p>The are many cool things that can be done with <code>&lt;pre&gt;</code> borders:</p>
										<ul>
										<li>Place a border on only one or two sides of the <code>&lt;pre&gt;</code> text</li>
										<li>Use varying widths and/or styles (e.g., dotted or custom image)</li>
										<li>Get all &ldquo;Web-2.0&rdquo; and <a href="http://perishablepress.com/press/2008/11/24/perfect-rounded-corners-with-css/" title="Perfect Rounded Corners with CSS">round your corners</a></li>
										</ul>
										<h4>Colors</h4>
										<p>Colors are another inspiring thing to play with when it comes to styling the presentation of your <code>&lt;pre&gt;</code> elements. You can color the text itself, the background, and the borders. Anything is possible here, I just wanted to point out that a good combination of colors for these different properties can really help your <code>&lt;pre&gt;</code> areas &ldquo;pop.&rdquo; Also fun to play with when choosing the perfect color combination is transparency, which might be used to let the background show through just a bit. Background images also present unlimited possibilities, such as adding a personal logo/icon or even a nice drop shadow for the upper/left border.</p>
										<h4>How I roll..</h4>
										<p>Last but not least, here is the template snippet that I use as a base for styling <code>&lt;pre&gt;</code> tags. After splicing this little snippet into my stylesheet, I proceed to tweak and fuss &lsquo;til everything&rsquo;s <em>just</em> right..</p>
										<pre><code>code, samp, kbd {
	font-family: "Courier New", Courier, monospace, sans-serif;
	text-align: left;
	color: #555;
	}
pre code {
	line-height: 1.6em;
	font-size: 11px;
	}
pre {
	padding: 0.1em 0.5em 0.3em 0.7em;
	border-left: 11px solid #ccc;
	margin: 1.7em 0 1.7em 0.3em;
	overflow: auto;
	width: 93%;
	}
/* target IE7 and IE6 */
*:first-child+html pre {
	padding-bottom: 2em;
	overflow-y: hidden;
	overflow: visible;
	overflow-x: auto; 
	}
* html pre { 
	padding-bottom: 2em;
	overflow: visible;
	overflow-x: auto;
	}</code></pre>
										<p>Rather than another long-winded diatribe exploring the manifold intricacies and subtleties of this particular stylistic strategy, I defer to your currently established comprehension of <acronym title="Cascading Style Sheets">CSS</acronym> and invite subsequent analysis of its constituent declarations. Or, in the parlance of the day: &ldquo;<em>it&rsquo;s plug-n-play, dude - I&rsquo;m outta here!!!</em>&rdquo;</p>
										<h3>Hungry for more</h3>
										<p>As mentioned, I post a lot of code here at Perishable Press. So much so, that I have become rather obsessed with the fine art of formatting and styling preformatted content. As <a href="http://twitter.com/perishable/status/5402269338" title="Lettin' em know">tweeted the other day</a>, I could spend all day just fussing over <code>&lt;pre&gt;</code> code. To me, it really is <em>that</em> important. In this article, I have shared many different techniques for creating perfect <code>&lt;pre&gt;</code> tags, but these methods are far from exhaustive. I am always on the lookout for new and useful ways to improve the appearance and functionality of my preformatted code examples, so if you happen to know any sweet tricks that I missed, share them and I will update the article with the method and link to your site.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/11/09/perfect-pre-tags/" title="Read 'Perfect &lt;pre&gt; Tags' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2006/08/21/a-complete-css-template-file/" title="A Complete CSS Template File (August 21, 2006)">A Complete CSS Template File</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/29/embed-flash-and-video-via-the-object-tag/" title="Embed Flash and Video via the object Tag (January 29, 2007)">Embed Flash and Video via the object Tag</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/12/prevent-javascript-elements-from-breaking-page-layout/" title="Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom (November 12, 2007)">Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/29/optimize-convoluted-code-via-javascript/" title="Optimize Convoluted Code via JavaScript (August 29, 2006)">Optimize Convoluted Code via JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/30/xhtml-document-header-resource/" title="XHTML Document Header Resource (August 30, 2006)">XHTML Document Header Resource</a></li>
					<li><a href="http://perishablepress.com/press/2006/10/04/one-link-to-open-them-all/" title="One Link to Open Them All (October 4, 2006)">One Link to Open Them All</a></li>
					<li><a href="http://perishablepress.com/press/2006/12/04/auto-focus-form-elements-with-javascript/" title="Auto-Focus Form Elements with JavaScript (December 4, 2006)">Auto-Focus Form Elements with JavaScript</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:smRIjhsDPrg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:smRIjhsDPrg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:smRIjhsDPrg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=7lQdqHh83IA:smRIjhsDPrg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=7lQdqHh83IA:smRIjhsDPrg:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/11/09/perfect-pre-tags/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pimp Your 404: Presentation and Functionality</title>
		<link>http://perishablepress.com/press/2009/11/02/pimp-your-404/</link>
		<comments>http://perishablepress.com/press/2009/11/02/pimp-your-404/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 15:46:18 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[404]]></category>

		<category><![CDATA[errors]]></category>

		<category><![CDATA[notes]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/11/02/pimp-your-404-presentation-and-functionality/</guid>
		<description><![CDATA[										I have been wanting to write about 404 error pages for quite awhile now. They have always been very important to me, with customized error pages playing a integral part of every well-rounded web-design strategy. Rather than try to re-invent the wheel with this, I think I will just go through and discuss some thoughts [...]]]></description>
			<content:encoded><![CDATA[										<p>I have been wanting to write about 404 error pages for quite awhile now. They have always been very important to me, with customized error pages playing a integral part of every well-rounded web-design strategy. Rather than try to re-invent the wheel with this, I think I will just go through and discuss some thoughts about 404 error pages, share some useful code snippets, and highlight some suggested resources along the way. In a sense, this post is nothing more than a giant &ldquo;brain-dump&rdquo; of all things 404 for future reference. Hopefully you will find it useful in pimping your own 404.</p>
										<blockquote><p>When requested page is not found by server, error message is returned; this is the essence of the 404 &#8212; Ancient Chinese proverb</p></blockquote>
										<h3>What is a 404 and why should I care?</h3>
										<p>Technically, you don&rsquo;t need to even <em>think</em> about 404 errors. They are handled automatically by server. But the problem is that, by default, your server is going to deliver one <strong>sick</strong>-looking message:</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-01.gif" alt="[ Screenshot: Default Apache 404 Error Page ]" /><br /><small>Default Apache 404 error page</small></p>
										<p>While that sort of message is fine for uber-geeky tech sites, chances are that &ldquo;normal&rdquo; visitors are going to crap themselves if they see such a thing, thinking:</p>
										<blockquote><p>What does that mean? Did I break something? I don&rsquo;t have time for this. I&rsquo;m outta here!</p></blockquote>
										<p>You don&rsquo;t want that, and neither do your visitors. Granted, most visitors are experienced enough to &ldquo;deal with it,&rdquo; but there are many that just don&rsquo;t understand. This is why many designers take the time to customize their 404 error pages to make them a little more &ldquo;user-friendly&rdquo; and not so bloody frightening. It&rsquo;s not like we&rsquo;re a bunch of robots, after all.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-02.jpg" alt="[ Screenshot: A 'user-friendly' 404 Error Page ]" /><br /><small><a href="http://fryewiles.com/templateserrors/404.html">A nice, &ldquo;user-friendly&rdquo; 404 error page</a></small></p>
										<p>Bottom line, here are three reasons why you should give a flying flip about 404 error pages:</p>
										<ul>
										<li>Default 404 errors are ugly and scary to regular people</li>
										<li>Default 404 errors may result in a higher bounce rate, because people are scared</li>
										<li>Custom 404 pages tell the reader that you care so much about them, and that it&rsquo;s &ldquo;all good&rdquo;</li>
										<li>User-friendly 404 pages draw the reader into your site, instead of scaring them away</li>
										<li>Default 404 errors are useless, but your custom 404 pages can actually <em>help</em> the user find what they are looking for</li>
										<li>You get the idea..</li>
										</ul>
										<p>In short, a well-designed 404 page keeps the user engaged and helps build trust. It just makes for an all-around better site.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-03.jpg" alt="[ Screenshot: Another 'user-friendly' 404 Error Page ]" /><br /><small><a href="http://headscape.co.uk/404">Another &ldquo;user-friendly&rdquo; 404 error page</a></small></p>
										<h3>I&rsquo;m sold, how do I do it?</h3>
										<p>Here are some tried and true <strong>best practices</strong> for creating that <em>perfect</em> 404 error page:</p>
										<dl>
										<dt>Keep it familiar</dt>
										<dd>Your custom error page should <em>look</em> like a well-integrated, natural part of your website. One of the reasons why default 404 error pages are so hideous is that they look so <em>alien</em> to your visitors. Unless your site is nothing but black serif fonts on plain white background, the default just isn&rsquo;t going to &ldquo;blend in.&rdquo; So keep it real, and make sure that your 404s (and other error pages) share the same design as the rest of your site.</dd>
										<dt>Explain the situation</dt>
										<dd>Everyone in their right mind understands that errors happen. There is no need to apologize for anything, but you <em>do</em> want to explain the situation. This doesn&rsquo;t have to be anything too serious, just a brief sentence or two telling the user that &ldquo;something happened&rdquo; and that the &ldquo;requested page was not found.&rdquo; Try to match the tone and flow of your site. If your site is formal, best to stay that way. If your site is hilarious, don&rsquo;t blow it on the 404.</dd>
										<dt>Provide some guidance</dt>
										<dd>A user sitting there staring at a 404 error page is obviously lost. Try to provide some guidance with a search bar, a site map, or perhaps a recipe for some strong, mixed drinks. There is a good chance that the visitor is looking for some of your popular content, so you may want to suggest a few popular site destinations. It is also helpful to include a search form (or a link to one), so that the user may report the error or ask a question about that darling resource they couldn&rsquo;t find.</dd>
										<dt>Display the requested URL</dt>
										<dd>As the user sits there scratching their head, it may be helpful to show them the <acronym title="Uniform Resource Locator">URL</acronym> that was received by the server. For example, the user may <em>think</em> that they entered &ldquo;<code>http://yoursite.com/blondie/</code>&rdquo;, but in reality they might have entered something like &ldquo;<code>http://yoursite.com/blodie/</code>&rdquo; instead. Echoing back the originally requested <acronym title="Uniform Resource Locator">URL</acronym> makes it easier for the user to spot any mistakes. Later in the article, we&rsquo;ll see a nice way to do this.</dd>
										<dt>Be mindful of file size</dt>
										<dd>As design guru <a href="http://css-tricks.com/404-best-practices/" title="404 Best Practices">Chris Coyier points out</a>, keeping an eye on the overall size of your 404 page is a good idea. Your 404 will be delivered for <em>every</em> missing request, not just the ones triggered by your visitors. This includes everything from <a href="http://perishablepress.com/press/2008/08/11/block-favicon-url-404-requests/" title="Stop the Madness: Redirect those Ridiculous Favicon 404 Requests">bizarre favicon requests</a> and <a href="http://perishablepress.com/press/2009/05/11/htaccess-spring-cleaning/" title="HTAccess Spring Cleaning 2009">non-existent robots.txt files</a> to missing scripts, stylesheets, images, and everything in-between. Needless to say, all of these 404s can add up quickly, so if bandwidth is an issue, be sure to keep an eye on total 404 size.</dd>
										<dt>Take advantage</dt>
										<dd>Just because life is sucking for the people who can&rsquo;t find your content doesn&rsquo;t mean that <em>you</em> can&rsquo;t benefit. When visitors trigger 404 errors, collect some data about the event so you can fix the issue and prevent further occurrences. For each 404 error, there is a great deal of information that is available to you, such as the requested <acronym title="Uniform Resource Locator">URL</acronym>, referrer info, <acronym title="Internet Protocol">IP</acronym> address, and much more. Once you have this data recorded somewhere, cleaning things up is much easier. Later in the article, we&rsquo;ll look at some cool code snippets to help you implement some keen functionality for your 404s.</dd>
										<dt>Have some fun</dt>
										<dd>A confused visitor is a scared visitor. The 404 page is a great opportunity to lighten things up with a little humor. Nothing <em>too</em> condescending, but just enough to let &lsquo;em know that you&rsquo;re on <em>their</em> side, and that you hate being lost just as much as they do. A quick laugh can gloss over just about anything, and you never know &#8212; if your page is clever enough, it might be featured in one of those ridiculously popular 404 error-page galleries&nbsp;;)</dd>
										</dl>
										<p>Later in the article, we&rsquo;ll check out some classic examples of effective and useful 404 pages. For now, let&rsquo;s see how to set &lsquo;em up..</p>
										<h3>How do I implement a custom 404 page?</h3>
										<p>That depends on how your site is setup. If you are running <a href="http://digwp.com/" title="Digging into WordPress">WordPress</a>, simply create a theme file named &ldquo;<code>404.php</code>&rdquo; and add whatever code and content you wish. Also in WordPress is the <strong>intra-page</strong> error, which is triggered when no content is found for a specific type of page view. Those familiar with <a href="http://perishablepress.com/press/tag/loops/" title="Perishable Press articles on the WordPress Loop">the WordPress loop</a> will recognize this as the portion of code located after the final <code>else</code> condition. This is not technically a 404 error &#8212; more like an intra-WordPress 404 &#8212; but it may also be customized and optimized for your visitors.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-04.gif" alt="[ Screenshot: The code responsible for the 'intra-WordPress 404' ]" /><br /><small>This portion of loop code is responsible for the &ldquo;intra-WordPress&rdquo; 404 error message</small></p>
										<p>For non-WordPress sites, the easiest way to override the default 404 page and deliver your own customized page is to tweak your <code>.</code><code>htaccess</code> with the following directive:</p>
										<pre><code>ErrorDocument 404 /error/404.php</code></pre>
										<p>This directive will replace the default 404 error page with the one specified (&ldquo;<code>/error/404.php</code>&rdquo; in our example). Edit the path according to the location of your custom file. Apache handles the rest. Thanks Apache.</p>
										<p>Check out my previous article for more information on <a href="http://perishablepress.com/press/2008/03/18/custom-http-errors-via-htaccess/" title="Custom HTTP Errors via htaccess">customizing error messages with <acronym title="Hypertext Access">HTAccess</acronym></a>. You can do much more than custom 404s!</p>
										<h3>Simply brilliant, let&rsquo;s see some code snippets</h3>
										<p>As mentioned, the underlying functionality of your 404 pages is just as important as the user-friendly interface. You could have the swellest 404 on teh Web, but unless you are actively working to resolve the errors, their frequency will inevitably increase. There are many awesome ways to track errors and enhance the underlying functionality of your 404 page. Here are some of my favorites.</p>
										<p><strong>Smart 404 for WordPress</strong><br /><a href="http://michael.tyson.id.au/2008/09/22/taking-the-404-further/" title="Taking the 404 further">Michael Tyson</a> shares this excellent method to make WordPress&rsquo; 404 handler a little bit smarter:</p>
										<blockquote cite="http://michael.tyson.id.au/2008/09/22/taking-the-404-further/"><p>I changed my template&rsquo;s 404 page to do a search for what the viewer was really after, and redirect them there. If it can&rsquo;t find an exact match, it&rsquo;ll perform a search with keywords extracted from the URL. If it finds a single result, it&rsquo;ll redirect, otherwise it&rsquo;ll put up a few results as suggestions on the 404 page.</p></blockquote>
										<p>Sounds nice, doesn&rsquo;t it. And extremely helpful as well. Here is the code to place into the top of your active theme&rsquo;s <code>404.php</code> file, immediately preceding the <code>get_header()</code> tag:</p>
										<pre><code>&lt;?php global $wp_the_query;
$search = preg_replace(array("@[_-]@", "@\.html$@"),array(" ",""),urldecode(basename($_SERVER["REQUEST_URI"])));
$posts = $wp_the_query-&gt;query(array("name" =&gt; $search));

if (count($posts) == 1) {
	wp_redirect(get_permalink($posts[0]-&gt;ID), 301);
	exit();
}
$posts = $wp_the_query-&gt;query(array("s" =&gt; $search));

if ( count($posts) == 1 ) {
	wp_redirect(get_permalink($posts[0]-&gt;ID), 301);
	exit();
} ?&gt;</code></pre>
										<p>That&rsquo;s the juice, right there. No editing required. Then, once that is in place, you can provide the user with some helpful suggestions. Just place this code somewhere within the <code>&lt;body&gt;</code> of your <code>404.php</code> page:</p>
										<pre><code>&lt;?php if (count($posts) &gt; 0) : ?&gt;
&lt;ul&gt;
&lt;?php foreach ($posts as $post) : ?&gt;

&lt;li&gt;&lt;a href="&lt;?php echo get_permalink($post-&gt;ID); ?&gt;"&gt;&lt;?php echo $post-&gt;post_title; ?&gt;&lt;/a&gt;&lt;/li&gt;

&lt;?php endforeach; ?&gt;
&lt;/ul&gt;
&lt;?php endif; ?&gt;</code></pre>
										<p>With that code in place, the user will see a list of potentially relevant list of posts that <em>may</em> include something useful or of interest. There is quite a bit that can be done with this technique, so have some fun with it.</p>
										<p><strong>Automatic notification emails with all the trimmings</strong></p>
										<p>Delivering user-friendly 404 pages to your visitors is great, but don&rsquo;t let that stop you from eliminating as many lost pages as possible. Cleaning up loose ends makes your site tighter, cleaner, and more usable. One way to keep an eye on your 404 errors is to simply crack open a log and dig in. In other situations, you may prefer to have the error information emailed to you in real-time. Here is a sweet little script that will do just that &#8212; send you an informative email every time a user triggers a 404 error. The email will contain a ton of related information, including everything from <acronym title="Internet Protocol">IP</acronym> address and server name to requested <acronym title="Uniform Resource Indicator">URI</acronym> and user agent. This strategy isn&rsquo;t recommended for high-volume sites, but for smaller blogs and niche sites, it may be just what the 404 doctor ordered. </p>
										<p>Here is the script that makes it happen:</p>
										<pre><code>&lt;?php 
// 404 auto-mailer script from Perishable Press
function errorEmailAlerts() {

	header("HTTP/1.1 404 Not Found");
	header("Status: 404 Not Found");

	// configure next two lines with your info

	$site  = "Your Site Name";
	$email = "your-email@address.com";

	// gather some data

	$http_host    = $_SERVER['HTTP_HOST'];
	$server_name  = $_SERVER['SERVER_NAME'];
	$remote_ip    = $_SERVER['REMOTE_ADDR'];
	$remote_host  = $_SERVER["REMOTE_HOST"];
	$request_uri  = $_SERVER['REQUEST_URI'];
	$cookie       = $_SERVER["HTTP_COOKIE"];
	$http_ref     = $_SERVER['HTTP_REFERER'];
	$query_string = $_SERVER['QUERY_STRING'];
	$user_agent   = $_SERVER['HTTP_USER_AGENT'];
	$error_date   = date("D M j Y g:i:s a T");

	// prepare teh email

	$subject = "404 Alert";

	$headers  = "Content-Type: text/plain"."\n";
	$headers .= "From: ".$site." &lt;".$email."&gt;"."\n";

	$message  = "404 Error Report for ".$site."\n";
	$message .= "Date: ".$error_date."\n";
	$message .= "Requested URL: http://".$http_host.$request_uri."\n";
	$message .= "Query String: ".$query_string."\n";
	$message .= "Cookie: ".$cookie."\n";
	$message .= "Referrer: ".$http_ref."\n";
	$message .= "User Agent: ".$user_agent."\n";
	$message .= "IP Address: ".$remote_ip." - ".$remote_host."\n";
	$message .= "Whois: http://ws.arin.net/cgi-bin/whois.pl?queryinput=".$remote_ip;

	// send teh email

	mail($email, $subject, $message, $headers);

} ?&gt;</code></pre>
										<p>Include this script in your active theme&rsquo;s <code>functions.php</code> file and edit the first two variables with your specific information. Then, place the following function call at the <em>very top</em> of your theme&rsquo;s <code>404.php</code> file:</p>
										<p><code>&lt;?php errorEmailAlerts(); ?&gt;</code></p>
										<p>Once in place and properly configured, this function will ensure that the proper 404 header is sent to the client, collect as much useful information as possible, and then send you an email with all the trimmings. Larger, high-volume sites may want to consider using a more robust method of logging and analyzing error data, but smaller, low-traffic sites and blogs will certainly benefit from tracking their 404 errors in real time.</p>
										<p><strong>Whitelist specific user-agents and URL-request patterns</strong></p>
										<p>As you begin to monitor your errors, you will inevitably discover three different types of 404:</p>
										<ul>
										<li>404 errors caused by malicious behavior (exploit scanning, etc.)</li>
										<li>404 errors caused by benign requests for non-existent resources</li>
										<li>legitimate 404 errors caused from missing resources or mistyped URLs</li>
										</ul>
										<p>Of these three types of 404 errors, the first is by far the most common. The Web is full of unscrupulous bastards who insist on spamming, cracking and exploiting even the humblest of sites. Here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, I devote many resources to the fighting of this type of malicious behavior, including <a href="http://perishablepress.com/press/tag/blacklist/" title="Tag Archive for 'Blacklist'">blacklists</a>, <a href="http://perishablepress.com/press/tag/php/" title="Tag Archive for 'PHP'">scripts</a>, and <a href="http://perishablepress.com/press/2008/05/25/series-summary-building-the-3g-blacklist/" title="Series Summary: Building the 3G Blacklist">education</a>. </p>
										<p>For the second type of 404 error, we are referring mainly to persistent requests made by otherwise benign scripts that check for the presence of legitimate, proprietary extensions, files, and other things. A good example of this is seen in <a href="http://www.virtual-presence.org/lms.html" title="Location Mapping System (LMS)">location mapping systems</a>, which typically request the following strings when crawling your site:</p>
										<ul>
										<li><code>http://domain.tld/path/resource/_vpi.xml</code></li>
										<li><code>http://domain.tld/path/resource/_vti_bin/</code></li>
										</ul>
										<p>These resources exist on servers that have been configured to accommodate visitors running programs such as Weblin. When they <em>are</em> discovered on a domain, they facilitate the discovery of site resources; when they <em>are not</em> found on a domain, the requests result in 404 errors. The number of these errors can be quite numerous and <a href="http://perishablepress.com/press/2008/05/31/blacklist-candidate-number-2008-05-31/" title="Blacklist Candidate Number 2008-05-31">may appear as malicious</a>.</p>
										<p>In addition to specific file requests, there are also certain <strong>user agents</strong> that may exhibit unusual behavior when crawling your site. Good examples of this include bots that don&rsquo;t understand fragment identifiers and search engines that try <a href="http://perishablepress.com/press/2007/08/13/suspicious-behavior-from-yahoo-slurp-crawler/" title="Suspicious Behavior from Yahoo! Slurp Crawler">guessing for the presence of expected resources</a>.</p>
										<p>To prevent these sorts of benign requests from polluting your 404 monitoring process, you can either <a href="http://perishablepress.com/press/2009/02/03/eight-ways-to-blacklist-with-apaches-mod_rewrite/" title="Eight Ways to Blacklist with Apache's mod_rewrite">blacklist</a> them or add them to a whitelist. To whitelist select agents, we can insert the following snippet into our previous <code>errorEmailAlerts()</code> function:</p>
										<pre><code>function errorEmailAlerts() {

	if (
		($_SERVER['HTTP_USER_AGENT'] != 'ia_archiver') &amp;&amp; 
		($_SERVER['HTTP_USER_AGENT'] != 'Yahoo! Slurp') &amp;&amp; 
		(strpos($request_uri, '/_vpi.xml') === false) &amp;&amp; 
		(strpos($request_uri, '/_vti_bin') === false)
		) {

		// function contents go here

	}

}</code></pre>
										<p>Once in place, this conditional statement will check for any &ldquo;whitelisted&rdquo; user agents and/or request strings in the <acronym title="Uniform Resource Locator">URL</acronym>. You can easily whitelist additional items by emulating the existing code. I am thinking this is self-explanatory, but don&rsquo;t hesitate to ask any specific questions in the comments section.</p>
										<h3>Fabulous, let&rsquo;s see some more examples of great 404 pages</h3>
										<p>Finally, let&rsquo;s wrap things up with a look at some great examples of 404 pages. Here are some of my favorite 404 error pages from around the Web.</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-05.jpg" alt="[ Screenshot: http://patterntap.com/404 ]" /><br /><small><a href="http://patterntap.com/404">http://patterntap.com/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-06.jpg" alt="[ Screenshot: http://www.expansionbroadcast.com/404 ]" /><br /><small><a href="http://www.expansionbroadcast.com/404">http://www.expansionbroadcast.com/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-07.jpg" alt="[ Screenshot: http://slonky.com/404 ]" /><br /><small><a href="http://slonky.com/404">http://slonky.com/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-08.jpg" alt="[ Screenshot: http://monzilla.biz/web/404 ]" /><br /><small><a href="http://monzilla.biz/web/404">http://monzilla.biz/web/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-09.jpg" alt="[ Screenshot: http://www.productplanner.com/404 ]" /><br /><small><a href="http://www.productplanner.com/404">http://www.productplanner.com/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-10.jpg" alt="[ Screenshot: http://thehpage.com/404 ]" /><br /><small><a href="http://thehpage.com/404">http://thehpage.com/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-11.jpg" alt="[ Screenshot: http://wakinglimb.com/404/ ]" /><br /><small><a href="http://wakinglimb.com/404/">http://wakinglimb.com/404/</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-12.jpg" alt="[ Screenshot: http://24-7media.de/404 ]" /><br /><small><a href="http://24-7media.de/404">http://24-7media.de/404</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-13.jpg" alt="[ Screenshot: http://southcreative.com.au/404.shtml ]" /><br /><small><a href="http://southcreative.com.au/404.shtml">http://southcreative.com.au/404.shtml</a></small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/pimp-your-404/404-14.jpg" alt="[ Screenshot: http://trentwalton.com/404 ]" /><br /><small><a href="http://trentwalton.com/404">http://trentwalton.com/404</a></small></p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/11/02/pimp-your-404/" title="Read 'Pimp Your 404: Presentation and Functionality' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2006/08/27/crazy-css-underline-effects/" title="Crazy CSS Underline Effects (August 27, 2006)">Crazy CSS Underline Effects</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/02/embed-external-content-via-iframe-and-div/" title="Embed External Content via iframe and div (January 2, 2007)">Embed External Content via iframe and div</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/10/keep-it-dark-hiding-and-filtering-css/" title="Keep it Dark: Hiding and Filtering CSS (January 10, 2007)">Keep it Dark: Hiding and Filtering CSS</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/15/industrial-strength-spamless-email-links/" title="Industrial-Strength Spamless Email Links (January 15, 2007)">Industrial-Strength Spamless Email Links</a></li>
					<li><a href="http://perishablepress.com/press/2007/07/09/windows-98-run-commands/" title="Computer Flashback: Windows 98 Run Commands (July 9, 2007)">Computer Flashback: Windows 98 Run Commands</a></li>
					<li><a href="http://perishablepress.com/press/2007/07/22/css-throwdown-preload-images-without-javascript/" title="CSS Throwdown: Preload Images without JavaScript (July 22, 2007)">CSS Throwdown: Preload Images without JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/16/preventing-the-unpredictable-white-screen-of-death-for-wordpress-sites-with-multiple-themes/" title="Preventing the Unpredictable White Screen of Death for WordPress Sites with Multiple Themes (June 16, 2008)">Preventing the Unpredictable White Screen of Death for WordPress Sites with Multiple Themes</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=JNmiB_S1NDw:z1xyJN0ExGA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=JNmiB_S1NDw:z1xyJN0ExGA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=JNmiB_S1NDw:z1xyJN0ExGA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=JNmiB_S1NDw:z1xyJN0ExGA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=JNmiB_S1NDw:z1xyJN0ExGA:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/11/02/pimp-your-404/feed/</wfw:commentRss>
		</item>
		<item>
		<title>4</title>
		<link>http://perishablepress.com/press/2009/10/25/4/</link>
		<comments>http://perishablepress.com/press/2009/10/25/4/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 15:48:56 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Perishable]]></category>

		<category><![CDATA[anniversary]]></category>

		<category><![CDATA[news]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/10/25/4/</guid>
		<description><![CDATA[										Time flies! Perishable Press celebrates its fourth year online during this Fall season. Not really sure what that means at this point, other than a lot of hard work, plenty of great conversation, and a ton of design-related content. How did I get here? Let&#8217;s take a brisk stroll down memory lane..
										During the site&#8217;s first [...]]]></description>
			<content:encoded><![CDATA[										<p>Time flies! <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> celebrates its <strong>fourth</strong> year online during this Fall season. Not really sure what that means at this point, other than a lot of hard work, plenty of great conversation, and a ton of design-related content. How did I get here? Let&rsquo;s take a brisk stroll down <a href="http://perishablepress.com/press/tag/anniversary/" title="See previous 'anniversary' posts">memory lane</a>..</p>
										<p><strong><a href="http://perishablepress.com/press/2006/11/08/one-year-anniversary/" title="One Year Anniversary">During the site&rsquo;s first year</a></strong>, I remember being too excited for my own good. WordPress was relatively new and I was completely inspired by the amazing things I could do with it. I spent most of my time building <a href="http://perishablepress.com/press/2008/04/06/perishable-press-theme-renovations-complete/" title="Select one of 18 different themes">all sorts of different themes</a>, studying web design, and posting useful code snippets. During this first year, Perishable Press was virtually unknown. Late night hours were spent drenched in <a href="http://perishablepress.com/press/tag/css/" title="CSS Tag Archive">CSS</a>, <a href="http://perishablepress.com/press/tag/xhtml/" title="(X)HTML Tag Archive">(X)HTML</a>, and <a href="http://perishablepress.com/press/tag/php/" title="PHP Tag Archive">PHP</a>.</p>
										<p><strong><a href="http://perishablepress.com/press/2007/11/10/perishable-press-turns-two/" title="Perishable Press Turns Two">During the site&rsquo;s second year</a></strong>, I delved deeper into web development, reading every blog, book, and comment I could get my hands on. I gobbled up knowledge like a hungry hungry hippo, and continued to post my discoveries and tricks. Some of the stuff I was posting began to assume more of a &ldquo;tutorial&rdquo; format, and this was back before tutorials were the highly refined gloss kits they are today. The site began getting a few links, and watched in amazement as my pages began to rank in the search engines. <a href="http://perishablepress.com/press/tag/seo/" title="SEO Tag Archive">SEO</a> was my new best friend, along with site <a href="http://perishablepress.com/press/tag/optimization/" title="Optimization Tag Archive">optimization</a>, <a href="http://perishablepress.com/press/tag/usability/" title="Usability Tag Archive">usability</a>, <a href="http://perishablepress.com/press/tag/accessibility/" title="Accessibility Tag Archive">accessibility</a>, and <a href="http://perishablepress.com/press/tag/performance/" title="Performance Tag Archive">performance</a>.</p>
										<p><strong><a href="http://perishablepress.com/press/2008/11/16/three-years-and-counting/" title="Three Years and Counting">During the site&rsquo;s third year</a></strong>, I continued sharpening my writing style, combining elaborate code descriptions with <a href="http://perishablepress.com/press/tag/tutorials/" title="Tutorial Tag Archive">in-depth tutorials</a> and <a href="http://perishablepress.com/press/tag/reference/" title="Reference Tag Archive">comprehensive guides</a> to a wide variety of development-related content. Traffic continued to increase, as did just about every other metric that I cared to look at. It was inspiring to know that people were <em>reading</em>, and that I was <em>helping</em> to give back to the incredible open-source design community from which I had learned so much. Site security became one of my primary concerns, and I continued to dive deep into the intoxicating pool of <a href="http://perishablepress.com/press/tag/htaccess/" title="HTAccess Tag Archive">HTAccess</a> and <a href="http://perishablepress.com/press/tag/blacklist/" title="Explore the 'blacklist' tag archive">next generation blacklists</a>.</p>
										<p><strong><a href="http://perishablepress.com/press/2008/10/25/4/" title="4">During the site&rsquo;s fourth year</a></strong>, I redesigned the site with <a href="http://perishablepress.com/press/2008/10/07/perishable-press-quintessential-screenshot-gallery/" title="Perishable Press Quintessential Screenshot Gallery">an elaborate, psychedelic theme</a>, and refined my content to include only the best material possible. Many of the shorter, quirkier posts were dropped in favor of more fully produced, well-researched articles on topics of broader interest than previously covered. Some awesome events happened during this most recent year, such as seeing my <a href="http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/" title="Stupid htaccess Tricks">stupid htaccess tricks</a> published in a <a href="http://www.packtpub.com/joomla-web-security-guide/book" title="Joomla! Web Security">book on Joomla Security</a>, and working with <a href="http://css-tricks.com/" title="Chris Coyier's CSS-Tricks">Chris Coyier of CSS-Tricks</a> on a new WordPress book, <a href="http://digwp.com/" title="Digging into WordPress">Digging into WordPress</a>.</p>
										<p><strong>During the site&rsquo;s upcoming fifth year</strong>, I will be rethinking everything. Design. Content. Delivery. Everything. I definitely want to take things to the next level. My plans are vast and ambitious, and I feel as if I am just getting started with this site. There is much in store for the future &#8212; <a href="http://perishablepress.com/press/feed/" title="Subscribe to Perishable Press">don&rsquo;t miss it</a>.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/10/25/4/" title="Read '4' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/11/16/three-years-and-counting/" title="Three Years and Counting (November 16, 2008)">Three Years and Counting</a></li>
					<li><a href="http://perishablepress.com/press/2006/05/21/gravatars-at-perishable-press/" title="Gravatars at Perishable Press (May 21, 2006)">Gravatars at Perishable Press</a></li>
					<li><a href="http://perishablepress.com/press/2006/07/24/press-time/" title="Press Time (July 24, 2006)">Press Time</a></li>
					<li><a href="http://perishablepress.com/press/2006/11/08/one-year-anniversary/" title="One Year Anniversary (November 8, 2006)">One Year Anniversary</a></li>
					<li><a href="http://perishablepress.com/press/2006/11/12/perishable-press-upgrade-to-wordpress-205/" title="Perishable Press Upgrade to WordPress 2.0.5 (November 12, 2006)">Perishable Press Upgrade to WordPress 2.0.5</a></li>
					<li><a href="http://perishablepress.com/press/2007/09/18/much-ado-about-taglines/" title="Much ado about Taglines (September 18, 2007)">Much ado about Taglines</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/14/miscellaneous-happenings/" title="Miscellaneous Happenings (October 14, 2007)">Miscellaneous Happenings</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=fgszbsn2KmA:Sc2U80nR8mg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=fgszbsn2KmA:Sc2U80nR8mg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=fgszbsn2KmA:Sc2U80nR8mg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=fgszbsn2KmA:Sc2U80nR8mg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=fgszbsn2KmA:Sc2U80nR8mg:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/10/25/4/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Stupid Twitter Tricks</title>
		<link>http://perishablepress.com/press/2009/10/18/stupid-twitter-tricks/</link>
		<comments>http://perishablepress.com/press/2009/10/18/stupid-twitter-tricks/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 17:13:48 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Blogging]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<category><![CDATA[twitter]]></category>

		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/10/18/stupid-twitter-tricks/</guid>
		<description><![CDATA[										 Might as well face it, Twitter is here to stay. Not that it&#8217;s all that bad, just used to be a lot more laid-back and enjoyable. These days it seems to have been taken over by the lowest common-denominator, mostly high-school twits or useless commercial propaganda. Even so, I still enjoy tweeting the occasional [...]]]></description>
			<content:encoded><![CDATA[										<p><img class="l" src="http://perishablepress.com/press/wp-content/images/2009/twitter-tricks/twitter-tricks_00.gif" alt="[ Twitter ]" /> Might as well face it, Twitter is here to stay. Not that it&rsquo;s all that bad, just used to be a lot more <a href="http://perishablepress.com/press/2009/01/04/thoughts-on-twitter/" title="Thoughts on Twitter">laid-back and enjoyable</a>. These days it seems to have been taken over by the lowest common-denominator, mostly high-school twits or useless commercial propaganda. Even so, I still enjoy tweeting the <a href="http://twitter.com/perishable" title="Follow Jeff Starr (Perishable) on Twitter!">occasional profound thought</a> once in awhile, and even like to play around with various types of &ldquo;advanced&rdquo; Twitter functionality. You know, cool stuff like including &ldquo;Tweet&nbsp;This!&rdquo; links with short <acronym title="Uniform Resource Locator">URL</acronym>s, showing off my number of Twitter followers, displaying the number of tweets for each post, and even backing up my marvelous tweets quickly and easily. As you might have guessed, these are the kind of stupid Twitter tricks that you will find in this article. So kick back, relax, and enjoy these twitterific techniques that will make you go <a href="http://twitter.com/home?status=Stupid+Twitter+Tricks%3A+http://tinyurl.com/yhz5ok3" title="Tweet this post!" rel="external">tweet</a>.</p>
										<h3>&ldquo;Tweet This!&rdquo; short links for posts</h3>
										<p>I like to include an easy way for readers to &ldquo;tweet&rdquo; my posts, but the <acronym title="Uniform Resource Locator">URL</acronym>s are generally way over Twitter&rsquo;s 140-character limit. Fortunately, we can use <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>&rsquo;s handy <code>file_get_contents</code> function to grab short versions of our <acronym title="Uniform Resource Locator">URL</acronym>s from a free minifying service like <a href="http://tinyurl.com/" title="TinyURL">TinyURL</a>.</p>
										<p>All we need to do is add the following script to your web pages or your <code>functions.php</code> file:</p>
										<pre><code>function shortenURL($longURL) {
	$shortURL = file_get_contents("http://tinyurl.com/api-create.php?url=".$longURL);
	echo $shortURL;
}</code></pre>
										<p>Then, in the location where you would like to display your shortened &ldquo;Tweet&nbsp;This!&rdquo; links (e.g., after your post loop), call the function and create the link with the following code:</p>
										<pre><code>&lt;a href="http://twitter.com/home?status=Reading:%20&lt;?php the_title(); ?&gt;:%20&lt;?php shortenURL(get_permalink()); ?&gt;" rel="nofollow"&gt;Tweet This!&lt;/a&gt;</code></pre>
										<p>This is basically a link using the Twitter <acronym title="Application Programming Interface">API</acronym> to specify the contents of our tweet. For each post, the value of <code>the_title()</code> and <code>get_permalink()</code> will change to reflect its title and <acronym title="Uniform Resource Locator">URL</acronym>, respectively. If you are using a platform other than WordPress, you will need to use the equivalent of these dynamic tags.</p>
										<p>Once you have this code in place, it will generate &ldquo;Tweet&nbsp;This!&rdquo; links that send the following information to Twitter (using this post as an example):</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/twitter-tricks/twitter-tricks_01.jpg" alt="[ Reading: Stupid Twitter Tricks: http://tinyurl.com/yhz5ok3 ]" /></p>
										<p>As you can see, the original long <acronym title="Uniform Resource Locator">URL</acronym> for this post was automatically shortened via the TinyURL service. Nice, clean and effective.</p>
										<p>For more social media links, check out my comprehensive article, <a href="http://perishablepress.com/press/2008/11/23/fully-valid-seo-friendly-social-media-links-for-wordpress/" title="Fully Valid, SEO-Friendly Social Media Links for WordPress">Fully Valid, SEO-Friendly Social Media Links for WordPress</a>.</p>
										<h3>Custom short links using your own domain name</h3>
										<p>If you would rather not rely on a shortening service (such as TinyURL) for your shortened links, fret not &#8212; it is easy to create your own, <em>customized</em> <acronym title="Uniform Resource Locator">URL</acronym>s. There are several good reasons why you might prefer to use your own domain for your shortened <acronym title="Uniform Resource Locator">URL</acronym>s, including:</p>
										<ul>
										<li>preservation of valuable link juice</li>
										<li>prevention of link loss if the shortening service dies</li>
										<li>control over the appearance and branding of your links</li>
										</ul>
										<p>The key to setting up customized shortened &ldquo;Tweet&nbsp;This!&rdquo; links is the inherent post ID that is associated with each of your posts. Regardless of whether or not you have permalinks setup, every one of your posts has its own unique post ID, such as seen in these examples:</p>
										<ul>
										<li><a href="http://perishablepress.com/press/?p=711" title="The Power of HTML 5 and CSS 3">http://perishablepress.com/press/?p=711</a></li>
										<li><a href="http://perishablepress.com/press/?p=712" title="The 5-Minute CSS Mobile Makeover ">http://perishablepress.com/press/?p=712</a></li>
										<li><a href="http://perishablepress.com/press/?p=713" title="Sexy HTML List Tricks ">http://perishablepress.com/press/?p=713</a></li>
										</ul>
										<p>We can use these post IDs to fashion our own shortened <acronym title="Uniform Resource Locator">URL</acronym>s, and then use those shortened <acronym title="Uniform Resource Locator">URL</acronym>s to create our own customized &ldquo;Tweet&nbsp;This!&rdquo; links. All we need is touch of <a href="http://perishablepress.com/press/tag/htaccess/" title="View all posts tagged as 'HTAccess'">HTAccess</a> placed in the same <code>.</code><code>htaccess</code> file as our WordPress permalinks:</p>
										<pre><code>RewriteRule ^x/([0-9]+)$ ?p=$1 [R=301,L]</code></pre>
										<p>This directive will redirect our custom shortened <acronym title="Uniform Resource Locator">URL</acronym>s to our default WordPress <acronym title="Uniform Resource Locator">URL</acronym>s, which WordPress will then redirect according to any existing permalink rules. Once this technique has been implemented, the following redirects will take place for each of your custom <acronym title="Uniform Resource Locator">URL</acronym>s:</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/twitter-tricks/twitter-tricks_02.gif" alt="[ Diagram showing the flow of redirects used in this technique ]" /></p>
										<p>Once we have the <acronym title="Hypertext Access">HTAccess</acronym> code in place, we use the same basic markup as in our previous example to create the link. Add the following code to the desired location in your theme file (e.g., after the post loop):</p>
										<pre><code>&lt;a href="http://twitter.com/home?status=Reading:%20&lt;?php the_title(); ?&gt;:%20&lt;?php echo get_option('home'); ?&gt;/x/&lt;?php the_ID(); ?&gt;" rel="nofollow"&gt;Tweet This!&lt;/a&gt;</code></pre>
										<p>This code will create &ldquo;Tweet&nbsp;This!&rdquo; links that send the following information to Twitter (using this post as an example):</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/twitter-tricks/twitter-tricks_03.jpg" alt="[ Reading: Stupid Twitter Tricks: http://perishablepress.com/x/719 ]" /></p>
										<p>As you can see, the original long <acronym title="Uniform Resource Locator">URL</acronym> for this post is now a customized short <acronym title="Uniform Resource Locator">URL</acronym> using the same domain. Feel free to change the &ldquo;<code>x</code>&rdquo; to whatever you want &#8212; just remember to edit both the markup link and the <code>.</code><code>htaccess</code> directive if you decide to do so.</p>
										<p>I should also note that, for any of these &ldquo;shortened&rdquo; <acronym title="Uniform Resource Locator">URL</acronym> examples, we are only using Twitter as an example application. Many sites these days simply include a shortened version of the post <acronym title="Uniform Resource Locator">URL</acronym> for people to copy &amp; paste anywhere they wish. To do something similar with the current technique, we would simply include the following snippet:</p>
										<p><code>&lt;?php echo get_option('home'); ?&gt;/x/&lt;?php the_ID(); ?&gt;</code></p>
										<h3>Drop-dead simple short URLs using the post ID</h3>
										<p>For the sake of completeness, keep in mind that we can use the post ID to (re)create our original WordPress <acronym title="Uniform Resource Locator">URL</acronym> structure:</p>
										<p><code>http://domain.tld/?p=719</code></p>
										<p>That&rsquo;s pretty short, and may work perfectly for your short links if the format is suitable for you. All we would need to do is include the following code into your WordPress theme:</p>
										<p><code>&lt;?php echo get_bloginfo('url')."/?p=".$post-&gt;ID; ?&gt;</code></p>
										<p>WordPress will automatically redirect such <acronym title="Uniform Resource Locator">URL</acronym>s to the corresponding permalink (if you have permalinks enabled).</p>
										<h3>Display the number of your Twitter followers in plain text via JavaScript</h3>
										<p>Another fun thing to do with Twitter is show off your subscriber number on your website. Many sites these days prominently display two numbers: one for their <a href="http://perishablepress.com/press/2009/01/25/feedburner-count-fallbacks/" title="PHP and JavaScript Fallbacks for Your Public Feedburner Count">Feedburner subscriber count</a> and another for their Twitter follower count. Displaying either count with a button or badge is a no-brainer, but displaying the numbers in plain text allows for greater stylistic control. Plain text is desirable because you can do just about anything with it, whereas a badge just kind of sits there, looking ugly.</p>
										<p>To get our Twitter follower count in plain text, we need to include some free JavaScript made available to us at <a href="http://twittercounter.com/pages/buttons" title="TwitterCounter">TwitterCounter</a>. Just place this code wherever you would like to display your follower count:</p>
										<pre><code>&lt;script type="text/javascript" language="javascript" src="http://twittercounter.com/widget/index.php?username=username"&gt;&lt;/script&gt;</code></pre>
										<p>Simply edit the &ldquo;<code>username</code>&rdquo; to match your own and you are off to the races.</p>
										<h3>Display the number of your Twitter followers in plain text via PHP</h3>
										<p>If you would rather not rely on JavaScript and a third-party service to deliver your follower count data, we can use <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>&rsquo;s excellent <code>curl()</code> functionality (edit the &ldquo;<code>www.domain.tld</code>&rdquo; to match your own):</p>
										<pre><code>function curl($url) {
	$ch = curl_init($url);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch,CURLOPT_HEADER, 0); 
	curl_setopt($ch,CURLOPT_USERAGENT,"www.domain.tld");
	curl_setopt($ch,CURLOPT_TIMEOUT,10); 
	$data = curl_exec($ch);
	curl_close($ch);
	return $data;
}</code></pre>
										<p>That curl snippet will grab the content of the input <acronym title="Uniform Resource Locator">URL</acronym> and prepare it for parsing via the following code:</p>
										<pre><code>function followerCount($username) {
	$followers = curl("http://twitter.com/statuses/user_timeline/".$username.".xml?count=1");
	$xml = new SimpleXmlElement($followers, LIBXML_NOCDATA);
	return = $xml-&gt;status-&gt;user-&gt;followers_count;
}
echo followerCount("username");</code></pre>
										<p>This second snippet uses <a href="http://php.net/manual/en/book.simplexml.php" title="SimpleXML">SimpleXML</a> to parse the curl output via the Twitter <acronym title="Application Programming Interface">API</acronym>. SimpleXML is pretty common on most servers running at least PHP&nbsp;5. The only thing you need to edit is the &ldquo;<code>username</code>&rdquo; in the last line. Everything else is roses. Drop this code into a web page and enjoy your follower count displayed anywhere you like, and in plain-text, no less.</p>
										<h3>Display the number of tweets for each page or post</h3>
										<p>If you are running SimpleXML (you probably are, ask your host), displaying the total number of tweets for any given post or page is easily accomplished with the following slice of <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>:</p>
										<pre><code>function tweetCount($url) {
	$content = file_get_contents("http://api.tweetmeme.com/url_info?url=".$url);
	$element = new SimpleXmlElement($content);
	$tweets = $element-&gt;story-&gt;url_count;
 	echo $tweets . " tweets!";
}</code></pre>
										<p>If you are using WordPress, you may place that code into your active theme&rsquo;s <code>functions.php</code> file. Then, to display the total number of tweets for your posts, you would add the following function call to your post loop:</p>
										<p><code>&lt;?php tweetCount($post-&gt;permalink); ?&gt;</code></p>
										<p>You can also show the number of tweets for a particular page, even if it is not on your site. For example:</p>
										<p><code>&lt;?php tweetCount("http://perishable.biz"); ?&gt;</code></p>
										<h3>Backup your tweets</h3>
										<p>Once you have been tweeting for awhile, you may begin to wonder what would happen if Twitter ever lost all of your tweets. It could happen, and if it does, do your tweets contain anything of value? If they do, I would highly recommend making regular backups (like monthly or something) of all your tweets. Doing so is easy. All you need to do is login to your Twitter account and enter the following <acronym title="Uniform Resource Locator">URL</acronym> into your browser:</p>
										<pre><code>http://twitter.com/statuses/user_timeline/username.xml?count=n</code></pre>
										<p>Before this will work, you need to replace the &ldquo;<code>username</code>&rdquo; with your actual username, and also change the &ldquo;<code>n</code>&rdquo; with the number of tweets you would like to download. To download all of your tweets, check your number of updates on your Twitter profile page. After entering this <acronym title="Uniform Resource Locator">URL</acronym> into your browser, you will be taken to an <acronym title="eXtensible Markup Language">XML</acronym> page containing your tweets. To make a backup, just save that page to a safe location on your computer.</p>
										<p>Now you can rest so easy just knowing deep down that all your precious tweets are safe and sound&nbsp;;)</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/10/18/stupid-twitter-tricks/" title="Read 'Stupid Twitter Tricks' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/11/23/fully-valid-seo-friendly-social-media-links-for-wordpress/" title="Fully Valid, SEO-Friendly Social Media Links for WordPress (November 23, 2008)">Fully Valid, SEO-Friendly Social Media Links for WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/27/conditionally-load-wordpress-pages/" title="Conditionally Load WordPress Pages (August 27, 2006)">Conditionally Load WordPress Pages</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/28/display-total-number-of-posts/" title="Display the Total Number of WordPress Posts, Comments, and Categories (August 28, 2006)">Display the Total Number of WordPress Posts, Comments, and Categories</a></li>
					<li><a href="http://perishablepress.com/press/2006/10/30/extreme-makeover-for-gravatars-in-wordpress/" title="Extreme Makeover for Gravatars in WordPress (October 30, 2006)">Extreme Makeover for Gravatars in WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2006/11/20/add-rss-feed-link-icons/" title="Add RSS Feed Link Icons to WordPress Category Listings (November 20, 2006)">Add RSS Feed Link Icons to WordPress Category Listings</a></li>
					<li><a href="http://perishablepress.com/press/2007/08/06/super-loop-exclude-specific-categories-and-display-any-number-of-posts/" title="Super Loop: Exclude Specific Categories and Display any Number of Posts (August 6, 2007)">Super Loop: Exclude Specific Categories and Display any Number of Posts</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/01/htaccess-combo-pack-wordpress-permalinks-and-non-www-redirect/" title="htaccess Combo Pack: WordPress Permalinks and non-www Redirect (October 1, 2007)">htaccess Combo Pack: WordPress Permalinks and non-www Redirect</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=FmgoIcExinE:MSKoLqSw-EI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=FmgoIcExinE:MSKoLqSw-EI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=FmgoIcExinE:MSKoLqSw-EI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=FmgoIcExinE:MSKoLqSw-EI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=FmgoIcExinE:MSKoLqSw-EI:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/10/18/stupid-twitter-tricks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTAccess Privacy for Specific IPs</title>
		<link>http://perishablepress.com/press/2009/10/12/htaccess-privacy-for-specific-ips/</link>
		<comments>http://perishablepress.com/press/2009/10/12/htaccess-privacy-for-specific-ips/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 16:29:00 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[blacklist]]></category>

		<category><![CDATA[htaccess]]></category>

		<category><![CDATA[ip]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/10/12/htaccess-privacy-for-specific-ips/</guid>
		<description><![CDATA[										Running a private site is all about preventing unwanted visitors. Here is a quick and easy way to allow access to multiple IP addresses while redirecting everyone else to a custom message page. 
										To do this, all you need is an HTAccess file and a list of IPs for which you would like to allow [...]]]></description>
			<content:encoded><![CDATA[										<p>Running a private site is all about <a href="http://perishablepress.com/press/2009/02/03/eight-ways-to-blacklist-with-apaches-mod_rewrite/" title="Eight Ways to Blacklist with Apache’s mod_rewrite">preventing unwanted visitors</a>. Here is a quick and easy way to allow access to multiple <acronym title="Internet Protocol">IP</acronym> addresses while redirecting everyone else to a custom message page. </p>
										<p>To do this, all you need is an <acronym title="Hypertext Access">HTAccess</acronym> file and a list of <acronym title="Internet Protocol">IP</acronym>s for which you would like to allow access.</p>
										<p>Edit the following code according to the proceeding instructions and place into the root <acronym title="Hypertext Access">HTAccess</acronym> file of your domain:</p>
										<pre><code># ALLOW ONLY MULTIPLE IPs
&lt;Limit GET POST PUT&gt;
 Order Deny,Allow
 Deny from all
 Allow from 123.456.789
 Allow from 456.789.123
 Allow from 789.123.456
&lt;/Limit&gt;
ErrorDocument 403 path/custom-message.html
&lt;Files path/custom-message.html&gt;
 Order Allow,Deny
 Allow from all
&lt;/Files&gt;</code></pre>
										<p>To prepare this code for use on your site, do these three things:</p>
										<ol>
										<li>Edit the three <acronym title="Internet Protocol">IP</acronym> addresses to suit your needs. Feel free to add more <acronym title="Internet Protocol">IP</acronym>s or remove any that aren&rsquo;t needed.</li>
										<li>Edit both instances of &ldquo;<code>path/custom-message.html</code>&rdquo; to match the path and file name of the file that will contain your custom message. This may be anything, anywhere, with any functionality you desire.</li>
										<li>That’s it. Copy/paste into your site&rsquo;s root htaccess file, upload, test, and get out!</li>
										</ol>
										<h3>The Obligatory Break-Down</h3>
										<p>How does the magic happen? HTAccess is esoteric voodoo for sure, but that&rsquo;s not going to stop us from understanding how it works. Here is the basic logic behind the operation:</p>
										<ul>
										<li>First deny access to everyone, then allow access only to the specified addresses.</li>
										<li>Serve everyone who doesn&rsquo;t have access a customized 403 (Forbidden) message.</li>
										<li>Ensure that everyone has access to the customized 403 (Forbidden) message.</li>
										</ul>
										<p>And here is a more in-depth, non-technical explanation of the various directives:</p>
										<dl>
										<dt><code>&lt;Limit GET POST PUT&gt;</code></dt>
										<dd>In the first line of our temporary redirect code, we open a <code>&lt;Limit&gt;</code> container targeting all requests to get, post, or put files to and from the server.</dd>
										<dt><code>Order Deny,Allow</code></dt>
										<dd>The second line then specifies the order in which the server should execute the proceeding directives. It basically says, &ldquo;first obey the deny rule and then obey the allow rule.&rdquo;</dd>
										<dt><code>Deny from all</code></dt>
										<dd>The next line is the deny rule. It simply says, &ldquo;deny everybody&rdquo; (i get like this sometimes). At this point in the game, everyone is denied access.</dd>
										<dt><code>allow from 123.456.789...</code></dt>
										<dd>The next three lines tell Apache to allow access to the specified addresses. As many or as few of these &ldquo;<code>allow</code>&rdquo; directives may be used to achieve your specific goals. Note that the directives used to this point serve as the first step of our logical sequence.</dd>
										<dt><code>&lt;/Limit&gt;</code></dt>
										<dd>The fifth line simply closes the <code>&lt;Limit&gt;</code> container block.</dd>
										<dt><code>ErrorDocument 403 path/custom.html</code></dt>
										<dd>In the sixth line, we are specifying our own customized error page. By default, a user that is denied access will see a simple error page that says something to the effect of &ldquo;403 Forbidden &#8212; You do not have authorization to access the requested resource.&rdquo; Not exactly encouraging. To improve this response, we specify our own customized error page and serve a much friendlier message, perhaps something like, &ldquo;This is a private site, but you can contact me for more information..&rdquo; Or something to that effect.</dd>
										<dt><code>&lt;Files path/custom-message.html&gt;</code></dt>
										<dd>After all that drama, the next line opens a <code>&lt;Files&gt;</code> container and exclusively targets our custom page. Note that you <em>could</em> omit the file path and just specify the file name, but doing so will apply the subsequent directives to <em>any</em> file named &ldquo;<code>custom-message.html</code>&rdquo; that exists within the directory structure. Either way, it is good practice to name your custom page something unique.</dd>
										<dt><code>Order Allow,Deny</code></dt>
										<dd>Again, we are specifying the order in which Apache should process the allow/deny directives.</dd>
										<dt><code>Allow from all</code></dt>
										<dd>This line then allows everyone access to the previously specified file. You know, the one with the inspiring, user-friendly message.</dd>
										<dt><code>&lt;/Files&gt;</code></dt>
										<dd>Finally, we conclude our <acronym title="Hypertext Access">HTAccess</acronym> redirect by closing the <code>&lt;Files&gt;</code> container. Taken together, the last four lines are basically telling the server to ignore the previous &ldquo;deny everybody&rdquo; directive only for the customized error page. All other pages remain strictly off-limits to anyone not on the guest list.</dd>
										</dl>
										<h3>The Wrap-Up</h3>
										<p>There you have it. To use this code, prepare your customized 403 document and upload to the desired location on your server. Edit the variables mentioned in the first part of this article, copy and paste to your root htaccess file, and upload to the root directory of your domain. Remember to check that everything has been done properly by using a proxy to test the redirect. Once everything is up and running, your site will be accessible only by select visitors, while everyone else will enjoy whatever custom message you may have prepared for them.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/10/12/htaccess-privacy-for-specific-ips/" title="Read 'HTAccess Privacy for Specific IPs' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2008/05/13/building-the-3g-blacklist-part-5/" title="Building the 3G Blacklist, Part 5: Improving Site Security by Selectively Blocking Individual IPs (May 13, 2008)">Building the 3G Blacklist, Part 5: Improving Site Security by Selectively Blocking Individual IPs</a></li>
					<li><a href="http://perishablepress.com/press/2008/05/25/series-summary-building-the-3g-blacklist/" title="Series Summary: Building the 3G Blacklist (May 25, 2008)">Series Summary: Building the 3G Blacklist</a></li>
					<li><a href="http://perishablepress.com/press/2009/03/08/building-the-perishable-press-4g-blacklist/" title="Building the Perishable Press 4G Blacklist (March 8, 2009)">Building the Perishable Press 4G Blacklist</a></li>
					<li><a href="http://perishablepress.com/press/2009/03/29/4g-ultimate-user-agent-blacklist/" title="4G Series: The Ultimate User-Agent Blacklist, Featuring Over 1200 Bad Bots (March 29, 2009)">4G Series: The Ultimate User-Agent Blacklist, Featuring Over 1200 Bad Bots</a></li>
					<li><a href="http://perishablepress.com/press/2009/04/21/4g-ultimate-referrer-blacklist/" title="4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers (April 21, 2009)">4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers</a></li>
					<li><a href="http://perishablepress.com/press/2007/06/28/ultimate-htaccess-blacklist/" title="Ultimate htaccess Blacklist (June 28, 2007)">Ultimate htaccess Blacklist</a></li>
					<li><a href="http://perishablepress.com/press/2007/07/23/permanently-redirect-a-specific-ip-request-for-a-single-page-via-htaccess/" title="Permanently Redirect a Specific IP Request for a Single Page via htaccess (July 23, 2007)">Permanently Redirect a Specific IP Request for a Single Page via htaccess</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5AKW6Yeuoj0:OLwBYvVMAzw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5AKW6Yeuoj0:OLwBYvVMAzw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5AKW6Yeuoj0:OLwBYvVMAzw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5AKW6Yeuoj0:OLwBYvVMAzw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5AKW6Yeuoj0:OLwBYvVMAzw:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/10/12/htaccess-privacy-for-specific-ips/feed/</wfw:commentRss>
		</item>
		<item>
		<title>How to Protect Your Site Against Content Thieves</title>
		<link>http://perishablepress.com/press/2009/09/23/protect-against-content-thieves/</link>
		<comments>http://perishablepress.com/press/2009/09/23/protect-against-content-thieves/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 18:19:25 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Blogging]]></category>

		<category><![CDATA[scrapers]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/09/23/protect-against-content-thieves/</guid>
		<description><![CDATA[										Stolen content is the bane of every blogger who provides a publicly available RSS feed. By delivering your content via feed, you make it easy for scrapers to assimilate and re-purpose your material on their crap Adsense sites. It&#8217;s bad enough that someone would re-post your entire feed without credit, but to use it for [...]]]></description>
			<content:encoded><![CDATA[										<p>Stolen content is the bane of every blogger who provides a publicly available <a href="http://perishablepress.com/press/2008/03/11/an-easy-introduction-to-web-feeds/" title="An Easy Introduction to Web Feeds">RSS feed</a>. By delivering your content via feed, you make it easy for scrapers to assimilate and re-purpose your material on their crap Adsense sites. It&rsquo;s bad enough that someone would re-post your entire feed without credit, but to use it for cheap money-making schemes is about as pathetic as it gets. If you&rsquo;re lucky, the bastards may leave all the links intact, so at least you will get a few back-links (if you have been linking internally) and get notified of the stolen content as well (via pingback or Google Alert). Lately, however, many of the scraper sites that I have seen are completely removing <em>all</em> links within the stolen content. Incidentally, there are some tell-tale signs that the site you are visiting is a scraper site:</p>
										<ul>
										<li>No <acronym title="Really Simple Syndication">RSS</acronym> feed available</li>
										<li>Many quality posts that contain no links</li>
										<li>Many quality posts but very low subscriber count</li>
										<li>Great content but with zero comments on any posts</li>
										<li>Lots of good content but with lots of Adsense or other ads</li>
										<li>No &ldquo;About&rdquo; page or business information</li>
										<li>And the number one brain-dead giveaway: <strong>no contact form or email address</strong></li>
										</ul>
										<p>If you pay attention as you surf around, you may want to keep an eye out for some of these dead giveaways. If it looks like the site is profiting from stolen content, it is advisable to leave immediately and locate an original source of information (you could even be cool and report the scraper site to the original author). I.e., help strengthen the <em>legit</em> blogging community and don&rsquo;t support scrapers in <em>any</em> way. But avoiding scraper sites is merely an afterthought. The <em>real</em> challenge is to have a solid strategy in place that will help you <strong>identify, eliminate and prevent stolen content</strong>. Unfortunately, there is no &ldquo;magic cure&rdquo; that will stop the scrapers from stealing your hard work &#8212; apart from running a private site or not providing a feed &#8212; but there are many great tools that have proven quite effective in fighting the war against stolen content. While not completely exhaustive, here are some powerful tips and tricks that have served me well over the years:</p>
										<dl>
										<dt>Use partial feeds</dt>
										<dd>This is arguably the most effect way to immunize against scrapers, who prefer to steal entire articles as opposed to excerpts.</dd>
										<dt>Use a monitoring service</dt>
										<dd>Services such as <a href="http://fairshare.cc/">Fairshare</a> or <a href="http://www.copyscape.com/">Copyscape</a> will help you find out who is stealing your content</dd>
										<dt>Use a feed footer plugin</dt>
										<dd>WordPress users have many to choose from including the excellent <a href="http://wordpress.org/extend/plugins/copyfeed/">Copyfeed</a> and <a href="http://planetozh.com/blog/my-projects/wordpress-plugin-better-feed-rss/" title="Wordpress Plugin : Better Feed">Ozh&rsquo; Better Feed</a>.</dd>
										<dt>Setup Google Alerts</dt>
										<dd>Keep an eye on what Google discovers around the Web. If you have a specific phrase or <acronym title="Uniform Resource Locator">URL</acronym> (perhaps your own) that appears in all (or most) of your posts, setup a comprehensive daily Google Alert to be notified any time that Google finds a match. This is particularly useful if you have pingbacks disabled at your site.</dd>
										<dt>Analyze your access logs</dt>
										<dd>Keep an eye out for image requests coming from external <acronym title="Internet Protocol">IP</acronym> addresses. These are usually associated with stolen content.</dd>
										<dt>Tell them to stop</dt>
										<dd>Stay vigilant and confront scrapers with formal &ldquo;Cease and Desist&ldquo; emails. <a href="http://www.domaintools.com/" title="domaintools.com">Gather information about the scraper</a> and then contact them as directly and clearly as possible. Tell them to cease and desist, include all relevant <acronym title="Uniform Resource Locator">URL</acronym>s, and explain the consequences of non-compliance. Then follow through.</dd>
										<dt>File a DMCA notice</dt>
										<dd>Take action by filing a formal <a href="http://www.google.com/dmca.html" title="Digital Millennium Copyright Act">DMCA notice</a> with each of the major search engines. If you are serious about stopping a scraper, filing a <a href="http://www.mcanerin.com/EN/articles/copyright-03.asp" title="Copyright Law and SEO Part 3">DMCA report</a> is an essential step in documenting and potentially resolving the situation. The process is slow and tedious, but worth the effort.</dd>
										<dt>Register your work</dt>
										<dd>To verify your work in the case of a dispute, register your content with services like <a href="http://www.numly.com/numly/default.asp" title="Numly">Numly</a> or <a href="http://www.registeredcommons.org/" title="Registered Commons">Registered Commons</a>. For situations when registering is not possible, <a href="http://www.archive.org/" title="Archive.org">Archive.org</a> may provide some indirect evidence of original authorship (just make sure you aren&#8217;t blocking them with your <a href="http://perishablepress.com/press/2006/04/03/robots-notes-plus/" title="Robots Notes Plus">robots.txt</a> file.</dd>
										<dt>Deliver your own feeds</dt>
										<dd>Rather than blacklist potential scrapers, target them directly by banning their <acronym title="Internet Protocol">IP</acronym> or user agent from accessing your feed. You can&#8217;t do this with Feedburner, but it is a great way to prevent stolen content.</dd>
										<dt>Blacklist by IP address</dt>
										<dd>Once you have determined the <acronym title="Internet Protocol">IP</acronym> of someone who is scraping your content, block them from accessing your feed by <a href="http://perishablepress.com/press/2009/02/03/eight-ways-to-blacklist-with-apaches-mod_rewrite/" title="Eight Ways to Blacklist with Apache’s mod_rewrite">blacklisting their address</a>. Something as simple as the following placed in your <acronym title="Hypertext Access">HTAccess</acronym> should do the trick:<br />
<code>RewriteCond %{REMOTE_ADDR} ^123.123.123</code><br />
<code>RewriteRule ^(.*)$ http://domain.tld/feed</code><br />
Replace the <acronym title="Internet Protocol">IP</acronym> address with that of the scraper and replace the feed <acronym title="Uniform Resource Locator">URL</acronym> with anything you wish. I prefer to use the feed of the scraper&rsquo;s site &#8212; works awesome&nbsp;;)</dd>
										<dt>Blacklist the User Agent</dt>
										<dd>If the scraper is using a unique or obscure User Agent when accessing your content, you can <a href="http://perishablepress.com/press/2009/03/29/4g-ultimate-user-agent-blacklist/" title="4G Series: The Ultimate User-Agent Blacklist, Featuring Over 1200 Bad Bots">blacklist that particular User Agent</a>.</dd>
										</dl>
										<p>And there are probably many other effective techniques to be found around the Web. The take-home point is that yes, scrapers suck, but there are many ways to prevent your content from being misused. Developing your own anti-scraping strategy while staying vigilant, informed, and proactive will definitely help minimize the degree to which scrapers misuse your content.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/09/23/protect-against-content-thieves/" title="Read 'How to Protect Your Site Against Content Thieves' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2005/11/21/get-real/" title="Get Real (November 21, 2005)">Get Real</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/15/industrial-strength-spamless-email-links/" title="Industrial-Strength Spamless Email Links (January 15, 2007)">Industrial-Strength Spamless Email Links</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/08/wordpress-spam-battle-3-seconds-that-will-save-you-hours-of-time/" title="WordPress Spam Battle: 3 Seconds that will Save You Hours of Time (October 8, 2007)">WordPress Spam Battle: 3 Seconds that will Save You Hours of Time</a></li>
					<li><a href="http://perishablepress.com/press/2007/10/31/bloggers-toolbox-strategic-elements-for-a-perfect-about-page/" title="Bloggers Toolbox: Strategic Elements for a Perfect About Page (October 31, 2007)">Bloggers Toolbox: Strategic Elements for a Perfect About Page</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/26/enable-file-or-directory-access-to-your-htaccess-password-protected-site/" title="Stupid htaccess Trick: Enable File or Directory Access to Your Password-Protected Site (November 26, 2007)">Stupid htaccess Trick: Enable File or Directory Access to Your Password-Protected Site</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/16/the-pros-and-cons-of-blogging/" title="The Pros and Cons of Blogging (April 16, 2008)">The Pros and Cons of Blogging</a></li>
					<li><a href="http://perishablepress.com/press/2008/05/04/building-the-3g-blacklist-part-1/" title="Building the 3G Blacklist, Part 1: Improving Site Security by Recognizing and Exploiting Server Attack Patterns (May 4, 2008)">Building the 3G Blacklist, Part 1: Improving Site Security by Recognizing and Exploiting Server Attack Patterns</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vAcoZMbwtCY:FuaX5qMRyZs:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vAcoZMbwtCY:FuaX5qMRyZs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vAcoZMbwtCY:FuaX5qMRyZs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=vAcoZMbwtCY:FuaX5qMRyZs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=vAcoZMbwtCY:FuaX5qMRyZs:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/09/23/protect-against-content-thieves/feed/</wfw:commentRss>
		</item>
		<item>
		<title>IDs are anchors, too.</title>
		<link>http://perishablepress.com/press/2009/09/14/ids-are-anchors-too/</link>
		<comments>http://perishablepress.com/press/2009/09/14/ids-are-anchors-too/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 16:19:08 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Structure]]></category>

		<category><![CDATA[markup]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/09/14/ids-are-anchors-too/</guid>
		<description><![CDATA[										While browsing the internet these days, I see a lot of this:
										&#60;body&#62;
...
&#60;a name="top"&#62;&#60;/a&#62;
...
&#60;a href="#top"&#62;- Back to Top -&#60;/a&#62;
...
&#60;/body&#62;
										There&#8217;s an easier, better and prettier way. CSS Signatures are all the rage these days. If you&#8217;re not familiar with a CSS Signature, it&#8217;s basically nothing more than an ID on your body tag, like this:
										&#60;body id="www-domain-tld"&#62;
										The fundamental [...]]]></description>
			<content:encoded><![CDATA[										<p>While browsing the internet these days, I see a lot of this:</p>
										<pre><code>&lt;body&gt;
...
&lt;a name="top"&gt;&lt;/a&gt;
...
&lt;a href="#top"&gt;- Back to Top -&lt;/a&gt;
...
&lt;/body&gt;</code></pre>
										<p>There&rsquo;s an easier, better and prettier way. <acronym title="Cascading Style Sheets">CSS</acronym> Signatures are all the rage these days. If you&rsquo;re not familiar with a <acronym title="Cascading Style Sheets">CSS</acronym> Signature, it&rsquo;s basically nothing more than an ID on your body tag, like this:</p>
										<pre><code>&lt;body id="www-domain-tld"&gt;</code></pre>
										<p>The fundamental purpose of the <acronym title="Cascading Style Sheets">CSS</acronym> Signature is to allow a user to specify style adjustments to your site in their own user style sheets. Whether or not users are actually capitalizing on this is a discussion for another day, but doing this has other benefits like having an extra id to use when dealing with <acronym title="Cascading Style Sheets">CSS</acronym> specificity.</p>
										<p>Additionally, we can use this to capitalize on a little known fact about <acronym title="Hypertext Markup Language">HTML</acronym> and anchors: you can use anchors to jump to any element on your page with an ID attribute.</p>
										<p>Let me repeat that: <strong>You can jump to any element with an ID attribute on any page.</strong></p>
										<p>Here&rsquo;s an example, if you don&rsquo;t believe me: Nowhere on CNN.com&rsquo;s homepage will you find a link to their footer, and you&rsquo;ll find no mention of <code>&lt;a name="cnnFooter"&gt;&lt;/a&gt;</code> in the code but if you follow this link to <a href="http://www.cnn.com/#cnnFooter" title="The Footer on the CNN.com Website">CNN</a> you will in fact find yourself staring at the footer on the CNN homepage. This is because their footer <code>div</code> has &ldquo;cnnFooter&rdquo; as <strong>the ID</strong> which allows me to jump directly to that element.</p>
										<p>Oh sure, I know what you&rsquo;re thinking: &ldquo;Great, so how do I get this to work in <acronym title="Internet Explorer">IE</acronym>?&rdquo; Surprise: it works just fine in <acronym title="Internet Explorer">IE</acronym>, at least as far back as <acronym title="Internet Explorer">IE</acronym> 5.5 and maybe further. So, here we have a nice, tidy little tidbit with no cross-browser issues.</p>
										<p>So, we can do away with the empty anchor element at the top of our pages and instead do this:</p>
										<pre><code>&lt;body id="www-domain-tld"&gt;
...
&lt;p&gt;&lt;a href="#www-domain-tld"&gt;- Back to Top -&lt;/a&gt;&lt;/p&gt;
...
&lt;/body&gt;</code></pre>
										<p>Trying to be all kinds of accessible with the &ldquo;Jump to Content&rdquo; link? Try this:</p>
										<pre><code>&lt;p&gt;
	&lt;a href="#content"&gt;- Jump to Content -&lt;/a&gt;
&lt;/p&gt;
...
&lt;div id="content"&gt;
	&lt;p&gt;Neat, huh?&lt;/p&gt;
&lt;/div&gt;</code></pre>
										<p>Also works well on comments:</p>
										<pre><code>&lt;p&gt;
  &lt;strong&gt;Update:&lt;/strong&gt;
  Based on &lt;a href="#comment-12345"&gt;so and so's comment&lt;/a&gt;...
&lt;/p&gt;
...
&lt;blockquote id="comment-12345"&gt;
  &lt;h3&gt;On Day X, so and so said:&lt;/h3&gt;
  &lt;p&gt;Blah blah blah...&lt;/p&gt;
&lt;/blockquote&gt;</code></pre>
										<p>&#8230;and comment forms:</p>
										<pre><code>&lt;p&gt;
  &lt;strong&gt;2 Responses&lt;/strong&gt;
  &lt;a href="#comment-form"&gt;- Jump to Comment Form -&lt;/a&gt;
&lt;/p&gt;
...
&lt;form id="comment-form" method="post" action=""&gt;
...
&lt;/form&gt;</code></pre>
										<p>Using this approach will streamline a lot of your code, allowing you to get rid of a ton of those empty anchor elements. It also allows for greater flexibility when linking to content on other&rsquo;s sites. Not to mention that using it means you can sit at the cool kid&rsquo;s table.</p>
										<h3>About the Author</h3>
										<p>Over the course of 33 years, <a href="http://www.macnimble.com/" title="MacNimble.com">Bill Brown</a> has lived and worked in West Africa as a Field Station Coordinator on Bioko Island in Equatorial Guinea, represented the Memorex line of consumer electronics on QVC, owned a squirrel, taught improvisation and stage combat and launched two successful improv comedy troupes. Oh, and along the way, he’s developed some websites and applications.</p>
										<p>Self-taught with a penchant for entertaining others, Bill’s clients have included internationally renowned photographer <a href="http://www.researchstevemccurry.com/" title="Steve McCurry's Research Website">Steve McCurry</a>, <a href="http://www.nmlea.org/" title="The National Maritime Law Enforcement Academy">The National Maritime Law Enforcement Academy</a> (whose site was developed entirely in the rain forests of Bioko Island), <a href="http://www.virtualgiving.com/" title="Virtual Giving">Virtual Giving</a>, <a href="http://www.workforcestrategy.org/" title="Workforce Strategy Center">Workforce Strategy Center</a> and the WSC web application <a href="http://www.pathwaystocompetitiveness.org/" title="WSC's Pathways to Competitiveness web application">Pathways to Competitiveness</a>. Bill was also a presenter at the 2008 National Association of Government Webmasters conference in Chicago, IL.</p>
										<p>Bill is the creator of WebDevelopedia.com and is an active member of several discussion lists, including the <a href="http://www.css-discuss.org/" title="The Cascading Style Sheets Discussion List">CSS Discussion List</a>. When not online, Bill can be found enjoying the company of his girlfriend, <a href="http://www.jessicaweinberg.com/" title="The Beautiful Photography of Jessica Weinberg">Jessica</a> and their dog, Leica (she doesn’t have a web site).</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/09/14/ids-are-anchors-too/" title="Read 'IDs are anchors, too.' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/01/02/embed-external-content-via-iframe-and-div/" title="Embed External Content via iframe and div (January 2, 2007)">Embed External Content via iframe and div</a></li>
					<li><a href="http://perishablepress.com/press/2007/09/25/absolute-horizontal-and-vertical-centering-via-css/" title="Absolute Horizontal and Vertical Centering via CSS (September 25, 2007)">Absolute Horizontal and Vertical Centering via CSS</a></li>
					<li><a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS (September 1, 2008)">Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS</a></li>
					<li><a href="http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/" title="Sexy HTML List Tricks (August 16, 2009)">Sexy HTML List Tricks</a></li>
					<li><a href="http://perishablepress.com/press/2006/09/04/fun-with-downlevel-conditional-comments/" title="Fun with Downlevel Conditional Comments (September 4, 2006)">Fun with Downlevel Conditional Comments</a></li>
					<li><a href="http://perishablepress.com/press/2006/10/04/one-link-to-open-them-all/" title="One Link to Open Them All (October 4, 2006)">One Link to Open Them All</a></li>
					<li><a href="http://perishablepress.com/press/2006/12/04/auto-focus-form-elements-with-javascript/" title="Auto-Focus Form Elements with JavaScript (December 4, 2006)">Auto-Focus Form Elements with JavaScript</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=eRaff9ZcHFg:AcaBZ6cZWDU:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=eRaff9ZcHFg:AcaBZ6cZWDU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=eRaff9ZcHFg:AcaBZ6cZWDU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=eRaff9ZcHFg:AcaBZ6cZWDU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=eRaff9ZcHFg:AcaBZ6cZWDU:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/09/14/ids-are-anchors-too/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Disable Trace and Track for Better Security</title>
		<link>http://perishablepress.com/press/2009/09/06/disable-trace-and-track-for-better-security/</link>
		<comments>http://perishablepress.com/press/2009/09/06/disable-trace-and-track-for-better-security/#comments</comments>
		<pubDate>Mon, 07 Sep 2009 04:28:21 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[htaccess]]></category>

		<category><![CDATA[http]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/09/06/disable-trace-and-track-for-better-security/</guid>
		<description><![CDATA[										The shared server on which I host Perishable Press was recently scanned by security software that revealed a significant security risk. Namely, the HTTP request methods TRACE and TRACK were found to be enabled on my webserver. The TRACE and TRACK protocols are HTTP methods used in the debugging of webserver connections.
										Although these methods are [...]]]></description>
			<content:encoded><![CDATA[										<p>The shared server on which I host <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a> was recently scanned by security software that revealed a significant security risk. Namely, the <acronym title="Hypertext Transfer Protocol">HTTP</acronym> request methods <code>TRACE</code> and <code>TRACK</code> were found to be enabled on my webserver. The <code>TRACE</code> and <code>TRACK</code> protocols are <acronym title="Hypertext Transfer Protocol">HTTP</acronym> methods used in the debugging of webserver connections.</p>
										<p>Although these methods are useful for legitimate purposes, they may compromise the security of your server by enabling cross-site scripting attacks (<acronym title="Cross-Site Tracing">XST</acronym>). By exploiting certain browser vulnerabilities, an attacker may manipulate the <code>TRACE</code> and <code>TRACK</code> methods to intercept your visitors&rsquo; sensitive data. The solution, of course, is disable these methods on your webserver.</p>
										<h3>How to disable the TRACE and TRACK methods</h3>
										<p>To disable <code>TRACE</code> and <code>TRACK</code> <acronym title="Hypertext Transfer Protocol">HTTP</acronym> methods on your Apache-powered webserver, add the following directives to either your main configuration file or root <acronym title="Hypertext Access">HTAccess</acronym> file:</p>
										<pre><code>RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]</code></pre>
										<p>These directives disable the <code>TRACE</code> and <code>TRACK</code> methods via the following process:</p>
										<ul>
										<li><code>RewriteEngine on</code> &#8212; enables Apache&rsquo;s rewrite module (this directive is not required if already present in your htaccess file)</li>
										<li><code>RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)</code> &#8212; targets all TRACE and TRACK request methods for the following rule</li>
										<li><code>RewriteRule .* - [F]</code> &#8212; return a <code>403 Forbidden</code> error response for all matched conditions (i.e., all TRACE and TRACK methods)</li>
										</ul>
										<p>With these rules in place, your site is protected against one more potential security vulnerability&nbsp;:)</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/09/06/disable-trace-and-track-for-better-security/" title="Read 'Disable Trace and Track for Better Security' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/11/26/enable-file-or-directory-access-to-your-htaccess-password-protected-site/" title="Stupid htaccess Trick: Enable File or Directory Access to Your Password-Protected Site (November 26, 2007)">Stupid htaccess Trick: Enable File or Directory Access to Your Password-Protected Site</a></li>
					<li><a href="http://perishablepress.com/press/2009/03/29/4g-ultimate-user-agent-blacklist/" title="4G Series: The Ultimate User-Agent Blacklist, Featuring Over 1200 Bad Bots (March 29, 2009)">4G Series: The Ultimate User-Agent Blacklist, Featuring Over 1200 Bad Bots</a></li>
					<li><a href="http://perishablepress.com/press/2009/04/21/4g-ultimate-referrer-blacklist/" title="4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers (April 21, 2009)">4G Series: The Ultimate Referrer Blacklist, Featuring Over 8000 Banned Referrers</a></li>
					<li><a href="http://perishablepress.com/press/2009/06/01/secure-visitor-posting-for-wordpress/" title="Secure Visitor Posting for WordPress (June 1, 2009)">Secure Visitor Posting for WordPress</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/15/industrial-strength-spamless-email-links/" title="Industrial-Strength Spamless Email Links (January 15, 2007)">Industrial-Strength Spamless Email Links</a></li>
					<li><a href="http://perishablepress.com/press/2007/07/23/permanently-redirect-a-specific-ip-request-for-a-single-page-via-htaccess/" title="Permanently Redirect a Specific IP Request for a Single Page via htaccess (July 23, 2007)">Permanently Redirect a Specific IP Request for a Single Page via htaccess</a></li>
					<li><a href="http://perishablepress.com/press/2007/08/01/temporary-site-redirect-for-visitors-during-site-updates/" title="Temporary Site Redirect for Visitors during Site Updates (August 1, 2007)">Temporary Site Redirect for Visitors during Site Updates</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=0J3ueglhSNo:Omzkl_qNXmo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=0J3ueglhSNo:Omzkl_qNXmo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=0J3ueglhSNo:Omzkl_qNXmo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=0J3ueglhSNo:Omzkl_qNXmo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=0J3ueglhSNo:Omzkl_qNXmo:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/09/06/disable-trace-and-track-for-better-security/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Tell Google to Not Index Certain Parts of Your Page</title>
		<link>http://perishablepress.com/press/2009/08/23/tell-google-to-not-index-certain-parts-of-your-page/</link>
		<comments>http://perishablepress.com/press/2009/08/23/tell-google-to-not-index-certain-parts-of-your-page/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 05:02:24 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Websites]]></category>

		<category><![CDATA[google]]></category>

		<category><![CDATA[nofollow]]></category>

		<category><![CDATA[robots]]></category>

		<category><![CDATA[search]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/08/23/tell-google-to-not-index-certain-parts-of-your-page/</guid>
		<description><![CDATA[										There are several ways to instruct Google to stay away from various pages in your site:
										
										Robots.txt directives
										Nofollow attributes on links
										Meta noindex/nofollow directives
										X-Robots noindex/nofollow directives
										
										..and so on. These directives all function in different ways, but they all serve the same basic purpose: control how Google crawls the various pages on your site. For example, you can [...]]]></description>
			<content:encoded><![CDATA[										<p>There are several ways to instruct Google to stay away from various pages in your site:</p>
										<ul>
										<li><a href="http://perishablepress.com/press/2006/04/03/robots-notes-plus/" title="Notes on the robots.txt tag">Robots.txt directives</a></li>
										<li><a href="http://perishablepress.com/press/2007/09/23/much-ado-about-nofollow-the-perishable-press-dofollow-series/" title="Much ado about nofollow: The Perishable Press Dofollow Series">Nofollow attributes on links</a></li>
										<li><a href="http://perishablepress.com/press/2006/08/30/xhtml-document-header-resource/" title="XHTML Document Header Resource">Meta noindex/nofollow directives</a></li>
										<li><a href="http://perishablepress.com/press/2008/06/03/taking-advantage-of-the-x-robots-tag/" title="Taking Advantage of the X-Robots Tag">X-Robots noindex/nofollow directives</a></li>
										</ul>
										<p>..and so on. These directives all function in different ways, but they all serve the same basic purpose: control how Google crawls the various pages on your site. For example, you can use meta noindex to instruct Google not to index your sitemap, <acronym title="Really Simple Syndication">RSS</acronym> feed, or any other page you wish. This level of control over which pages are crawled and indexed is helpful, but what if you need to control how Google crawls the contents of a specific page? Easy. Google enables us to do this with a set of <code>googleon</code>/<code>googleoff</code> tags.</p>
										<h3>About googleon and googleoff tags</h3>
										<p>Put simply, the <code>googleon</code>/<code>googleoff</code> tags tell <strike>GoogleBot</strike> Google Search Appliance when to start and stop indexing various parts of the web document. Consider the following example:</p>
										<pre><code>&lt;p&gt;This is normal (X)HTML content that will be indexed by Google.&lt;/p&gt;

&lt;!--googleoff: index--&gt;

&lt;p&gt;This (X)HTML content will NOT be indexed by Google.&lt;/p&gt;

&lt;!--googleon: index&gt;</code></pre>
										<p>In this example, we see how the <code>googleon</code>/<code>googleoff</code> tags will prevent the second paragraph from being indexed by Google. Notice the &ldquo;<code>index</code>&rdquo; parameter, which may be set to any of the following:</p>
										<ul>
										<li><strong>index</strong> &#8212; content surrounded by &ldquo;<code>googleoff:</code>&nbsp;<code>index</code>&rdquo; will not be indexed by Google</li>
										<li><strong>anchor</strong> &#8212; anchor text for any links within a &ldquo;<code>googleoff:</code>&nbsp;<code>anchor</code>&rdquo; area will not be associated with the target page</li>
										<li><strong>snippet</strong> &#8212; content surrounded by &ldquo;<code>googleoff:</code>&nbsp;<code>snippet</code>&rdquo; will not be used to create snippets for search results</li>
										<li><strong>all</strong> &#8212; content surrounded by &ldquo;<code>googleoff:</code>&nbsp;<code>all</code>&rdquo; are treated with all attributes: index, anchor, and snippet</li>
										</ul>
										<p>Cool, eh? Let&rsquo;s have a look at a specific usage example..</p>
										<h3>Using googleon and googleoff tags</h3>
										<p><strong>Example 1: Blog Comments</strong><br />Let&rsquo;s say your comment threads tend to stray into off-topic conversation. Keeping your pages as tightly focused on the subject at hand is a great way to improve the on-page relevancy of your targeted keywords while improving the accuracy of matching search queries. Thus, to keep the superfluous banter out of the Google index, you could add <code>googleon</code>/<code>googleoff</code> tags as follows:</p>
										<pre><code>&lt;!--googleoff: all--&gt;

&lt;div id="comments"&gt;

   &lt;p&gt;&lt;strong&gt;Nick Mason&lt;/strong&gt; - August 2nd, 2009&lt;/p&gt;
   &lt;p&gt;From Her Majesty the queen. His boots were very clean.&lt;/p&gt;

   &lt;p&gt;&lt;strong&gt;Rick Wright&lt;/strong&gt; - August 3rd, 2009&lt;/p&gt;
   &lt;p&gt;Every year is getting shorter, never seem to find the time.&lt;/p&gt;

   &lt;p&gt;&lt;strong&gt;David Gilmour&lt;/strong&gt; - August 4th, 2009&lt;/p&gt;
   &lt;p&gt;By the river holding hands roll me up and lay me down.&lt;/p&gt;

   &lt;p&gt;&lt;strong&gt;Roger Waters&lt;/strong&gt; - August 5th, 2009&lt;/p&gt;
   &lt;p&gt;And after a while, you can work on points for style.&lt;/p&gt;

&lt;/div&gt;

&lt;!--googleon: all&gt;</code></pre>
										<p>We definitely don&rsquo;t want to see such a mindless thread in Google, and it will be interesting to see if the <code>&lt;pre&gt;</code> example gets dropped from the index..</p>
										<h3>May the Force be with You</h3>
										<p>While using this method to control how Google indexes your on-page content, there are a couple of things you should keep in mind. First, there is a difference between <em>indexing</em> and <em>crawling</em>. Google may crawl portions of your page that are demarcated with <code>googleon</code>/<code>googleoff</code> tags. So in case you were thinking that this technique may be a way to deal with <a href="http://thenexus.tk/google-new-nofollow-policy/" title="Dealing with Google’s New Nofollow Policy">Google&rsquo;s new nofollow policy</a>, forget about it &#8212; PageRank will continue to flow through any links contained within a <code>googleoff</code> zone.</p>
										<p>Besides this, also keep in mind that this is a proprietary technique supported exclusively by Google Search Appliance. If you have content that you want to keep out of the index of <em>all</em> search engines, then you will need to find <a href="http://digwp.com/2009/08/password-protect-more-than-the_content/" title="Password Protect More Than the_content()">another way to do it</a>. Eventually, Yahoo! and MSN/Live/Bing/Whatever may create proprietary &ldquo;on/off tags&rdquo; of their own, but chances are slim to none that they will obey the proprietary technology of the mighty Google.</p>
										<p>For more information about googleon/googleoff tags, check out Google&rsquo;s <a href="http://code.google.com/apis/searchappliance/documentation/46/admin_crawl/Preparing.html" title="Administering Crawl for Web and File Share Content: Preparing for a Crawl ">official documentation</a>.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/08/23/tell-google-to-not-index-certain-parts-of-your-page/" title="Read 'Tell Google to Not Index Certain Parts of Your Page' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/08/29/stop-wordpress-from-leaking-pagerank-to-admin-pages/" title="Stop WordPress from Leaking PageRank to Admin Pages (August 29, 2007)">Stop WordPress from Leaking PageRank to Admin Pages</a></li>
					<li><a href="http://perishablepress.com/press/2008/07/30/choosing-the-best-title-separators/" title="Choosing the Best Title Separators (July 30, 2008)">Choosing the Best Title Separators</a></li>
					<li><a href="http://perishablepress.com/press/2008/12/07/custom-opensearch-functionality-for-your-website/" title="Custom OpenSearch Functionality for Your Website (December 7, 2008)">Custom OpenSearch Functionality for Your Website</a></li>
					<li><a href="http://perishablepress.com/press/2008/12/09/valid-seo-friendly-post-translation-links/" title="Valid, SEO-Friendly Post Translation Links (December 9, 2008)">Valid, SEO-Friendly Post Translation Links</a></li>
					<li><a href="http://perishablepress.com/press/2009/05/10/seo-experiment-let-google-sort-it-out/" title="SEO Experiment: Let Google Sort it Out (May 10, 2009)">SEO Experiment: Let Google Sort it Out</a></li>
					<li><a href="http://perishablepress.com/press/2009/06/14/insert-links-external-javascript/" title="Dynamic Link Insertion via Unobtrusive External JavaScript (June 14, 2009)">Dynamic Link Insertion via Unobtrusive External JavaScript</a></li>
					<li><a href="http://perishablepress.com/press/2006/04/03/robots-notes-plus/" title="Robots Notes Plus (April 3, 2006)">Robots Notes Plus</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=BEWm3R-6MV0:dWBJRRxJS8s:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=BEWm3R-6MV0:dWBJRRxJS8s:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=BEWm3R-6MV0:dWBJRRxJS8s:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=BEWm3R-6MV0:dWBJRRxJS8s:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=BEWm3R-6MV0:dWBJRRxJS8s:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/08/23/tell-google-to-not-index-certain-parts-of-your-page/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sexy HTML List Tricks</title>
		<link>http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/</link>
		<comments>http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 04:41:23 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[Structure]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[format]]></category>

		<category><![CDATA[list]]></category>

		<category><![CDATA[markup]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/</guid>
		<description><![CDATA[										Behold the ubiquitous list elements, &#60;ul&#62; and &#60;ol&#62;! These two sexy elements help millions of websites display lists of information in clean, semantic fashion. Without them, we&#8217;d be crawling around like filthy cavemen, eating dirt and howling at the moon. 
										But these list elements aren&#8217;t just sexy, they are also extremely flexible, enabling us humble [...]]]></description>
			<content:encoded><![CDATA[										<p>Behold the ubiquitous list elements, <code>&lt;ul&gt;</code> and <code>&lt;ol&gt;</code>! These two <em>sexy</em> elements help millions of websites display lists of information in clean, semantic fashion. Without them, we&rsquo;d be crawling around like filthy cavemen, eating dirt and howling at the moon. </p>
										<p>But these list elements aren&rsquo;t just <em>sexy</em>, they are also extremely <em>flexible</em>, enabling us humble designers to create robust list configurations that are semantically versatile and highly customizable. We all know how to throw down a basic list:</p>
										<pre><code>&lt;ul&gt;
	&lt;li&gt;Pancakes&lt;/li&gt;
	&lt;li&gt;Bananas&lt;/li&gt;
	&lt;li&gt;Monkeys&lt;/li&gt;
&lt;/ul&gt;</code></pre>
										<p>Or even throw down some hardcore nested-list action:</p>
										<pre><code>&lt;ul&gt;
	&lt;li&gt;Pancakes
		&lt;ol&gt;
			&lt;li&gt;Swedish&lt;/li&gt;
			&lt;li&gt;Blueberry&lt;/li&gt;
			&lt;li&gt;Chocolate&lt;/li&gt;
		&lt;/ol&gt;
	&lt;/li&gt;
	&lt;li&gt;Bananas
		&lt;ol&gt;
			&lt;li&gt;Manzano&lt;/li&gt;
			&lt;li&gt;Plantain&lt;/li&gt;
			&lt;li&gt;Cavendish&lt;/li&gt;
		&lt;/ol&gt;
	&lt;/li&gt;
	&lt;li&gt;Monkeys
		&lt;ol&gt;
			&lt;li&gt;Spider&lt;/li&gt;
			&lt;li&gt;Howler&lt;/li&gt;
			&lt;li&gt;Squirrel&lt;/li&gt;
		&lt;/ol&gt;
	&lt;/li&gt;
&lt;/ul&gt;</code></pre>
										<p>This nested list markup will result in a unordered bulleted parent list with numerically ordered nested lists, resulting in something like this in a browser:</p>
										<ul>
										<li>Pancakes
										<ol>
										<li>Swedish</li>
										<li>Blueberry</li>
										<li>Chocolate</li>
										</ol>
										</li>
										<li>Bananas
										<ol>
										<li>Manzano</li>
										<li>Plantain</li>
										<li>Cavendish</li>
										</ol>
										</li>
										<li>Monkeys
										<ol>
										<li>Spider</li>
										<li>Howler</li>
										<li>Squirrel</li>
										</ol>
										</li>
										</ul>
										<p>Of course, we can style the display of this list configuration with some super-sexy <acronym title="Cascading Style Sheets">CSS</acronym>. For example, we can change the appearance of both ordered (&nbsp;<code>&lt;ol&gt;</code>&nbsp;) and unordered (&nbsp;<code>&lt;ul&gt;</code>&nbsp;) list  markers by specifying one of the following types:</p>
										<pre><code>ul, ol {
	list-style-type: none;                 /* no list marker */
	list-style-type: disc;                 /* filled circles */
	list-style-type: square;               /* square markers */
	list-style-type: circle;               /* circle markers */
	list-style-type: inherit;              /* inherits style */
	list-style-type: decimal;              /* number markers */
	list-style-type: decimal-leading-zero; /* 01, 02, 03, .. */
	list-style-type: lower-alpha;          /* a, b, c, d, .. */
	list-style-type: lower-latin;          /* a, b, c, d, .. */
	list-style-type: lower-greek;          /* alpha, beta .. */
	list-style-type: lower-roman;          /* i, ii, iii, .. */
	list-style-type: upper-alpha;          /* A, B, C, D, .. */
	list-style-type: upper-latin;          /* A, B, C, D, .. */
	list-style-type: upper-roman;          /* I, II, III, .. */
	}</code></pre>
										<p>And, as if those options weren&rsquo;t enough, <acronym title="Cascading Style Sheets">CSS</acronym> also enables us to use <em>any</em> list marker imaginable via the incredibly sexy <code>list-style-image</code> property. For example, we could create a small <acronym title="">GIF</acronym> image of a banana and use it as a list marker with the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>ul, ol {
	list-style-image: url(banana.gif);
	}</code></pre>
										<p>This technique is also possible by setting a <code>background-image</code> for the individual list (&nbsp;<code>&lt;li&gt;</code>&nbsp;) items, thereby providing a greater degree of presentational control:</p>
										<pre><code>ul li, ol li {
	background-image: url(banana.gif);
	}</code></pre>
										<p>We can even combine these methods to establish a built-in fallback mechanism that will enable the custom list-marker images to degrade gracefully to any list-style type. While we&rsquo;re at it, let&rsquo;s change the position of the list markers to appear within the list element itself:</p>
										<pre><code>ul {
	list-style-image: url(banana.gif);
	list-style-position: inside;
	list-style-type: circle;
	}</code></pre>
										<p>This will give us an unordered list that displays our custom <code>banana.gif</code> marker if supported, else the list markers will be displayed as circles. Further, the list markers in this example will be displayed on the <em>inside</em> of the list items. To conserve resources, we may combine these three rules into the following &ldquo;shortcut&rdquo; declaration:</p>
										<pre><code>ul {
	list-style: circle url(banana.gif) inside;
	}</code></pre>
										<p>If we wanted to display the list <em>without</em> markers, there are two ways to prevent long strings of list text from extending past the first line, for example:</p>
										<pre><code>  Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, 
Lorem ipsum blah blah blah, Lorem ipsum blah blah blah,

  Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, 
Lorem ipsum blah blah blah, Lorem ipsum blah blah blah,

  Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, 
Lorem ipsum blah blah blah, Lorem ipsum blah blah blah.</code></pre>
										<p>This case happens when the <code>list-style-position</code> is set to <code>inside</code> and the list text wraps onto subsequent lines. So, to alleviate this awkward list display, simply remove the <code>list-style-position:inside</code> declaration or explicitly specify it as <code>list-style-position:outside;</code>. Alternately, if you simply <em>must</em> use an inline display-type, you can prevent subsequent lines from &ldquo;underlapping&rdquo; the first line by using the oft-overlooked <code>text-indent</code> property:</p>
										<pre><code>ul {
	list-style-position: inside;
	text-indent: -0.7em;
	list-style: none;
	}</code></pre>
										<p>The <code>text-indent</code> technique is also useful when using generated content for your list markers. For example, by generating list markers with the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>ul {
	list-style: none;
	}
ul li:before {
	content: "\00BB \0020";
	}</code></pre>
										<p>You will see this for short list items:</p>
										<style type="text/css">
ul.pancakes-list-demo, ul.pancakes-list-demo li {
	list-style: none;
	}
ul.pancakes-list-demo li:before {
	content: "\00BB \0020";
	}
</style>
										<ul class="pancakes-list-demo">
										<li>Pancakes</li>
										<li>Bananas</li>
										<li>Monkeys</li>
										</ul>
										<p>And this for long list items:</p>
										<ul class="pancakes-list-demo">
										<li>Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah. Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah.</li>
										<li>Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah. Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah.</li>
										<li>Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah. Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah, Lorem ipsum blah blah blah.</li>
										</ul>
										<p>Ugh! There&rsquo;s that nasty underlapping text wrap again. This happens because the generated content is inserted <em>within</em> the list elements. Unfortunately, setting the display-type to <code>outside</code> does not help in this scenario. Fortunately, we can easily resolve this issue by including a <code>text-indent</code> declaration to our previous list styles:</p>
										<pre><code>ul {
	text-indent: -1em;
	list-style: none;
	}
ul li:before {
	content: "\00BB \0020";
	}</code></pre>
										<p>Problem solved. At this point, you may be thinking, &ldquo;what&rsquo;s with all of that funky &lsquo;generated content&rsquo; stuff?&rdquo; If so, allow me to explain.</p>
										<p><acronym title="Cascading Style Sheets">CSS</acronym> 2.1 provides us with tools that enable us to insert various types of content into our markup. By combining the <code>:before</code> or <code>:after</code> pseudo-selectors and the <code>content</code> property, we can add alphanumeric and special characters into our document via the stylesheet. The characters that may be inserted may be alphanumeric text strings or escaped hexadecimal character equivalents such as the following:</p>
										<ul>
										<li><code>\0020</code> &#8212; blank space, unicode = <code>&amp;nbsp;</code></li>
										<li><code>\21D3</code> &#8212; down arrow, unicode = <code>&amp;dArr;</code> (&nbsp;&dArr;&nbsp;)</li>
										<li><code>\00BB</code> &#8212; right double angle quote, unicode = <code>&amp;raquo;</code> (&nbsp;&raquo;&nbsp;)</li>
										</ul>
										<p>But wait, there&rsquo;s more! Using <acronym title="Cascading Style Sheets">CSS</acronym> may be the modern, &ldquo;Web-Standards&rdquo; way of configuring the presentation of list elements, but there are also some interesting and useful <em>inline</em> tricks that, although deprecated, prove a delightful romp nonetheless. Let&rsquo;s peek into the past, shall we?</p>
										<p>First, the list-style <code>type</code> property may be specified inline for <code>&lt;ul&gt;</code> (and even <code>&lt;li&gt;</code>) elements:</p>
										<pre><code>&lt;ul type=circle&gt;
	&lt;li&gt;Telegraph&lt;/li&gt;
	&lt;li&gt;Telephone&lt;/li&gt;
	&lt;li&gt;Mobile phone&lt;/li&gt;
&lt;/ul&gt;</code></pre>
										<p>For <em>unordered</em> lists, the accepted values are <code>circle</code>, <code>square</code>, and <code>disc</code>. For <em>ordered</em> lists, the accepted property values are <code>A</code>, <code>a</code>, <code>I</code>, <code>i</code>, and <code>1</code>. Here is an example:</p>
										<pre><code>&lt;ol type=A&gt;
	&lt;li&gt;Atari&lt;/li&gt;
	&lt;li&gt;Nintendo&lt;/li&gt;
	&lt;li&gt;Playstation&lt;/li&gt;
&lt;/ul&gt;</code></pre>
										<p>Here is a breakdown of the accepted values for the <code>type</code> property:</p>
										<ul>
										<li><code>circle</code> &#8212; circle markers</li>
										<li><code>square</code> &#8212; square markers</li>
										<li><code>disc</code> &#8212; disc markers</li>
										<li><code>A</code> &#8212; uppercase letters</li>
										<li><code>a</code> &#8212; lowercase letters</li>
										<li><code>I</code> &#8212; uppercase roman</li>
										<li><code>i</code> &#8212; lowercase roman</li>
										<li><code>1</code> &#8212; default markers</li>
										</ul>
										<p>That&rsquo;s all fine and well, but something that is far more useful is the ability to set specific values for various list items. By using the deprecated <code>value</code> attribute applied to the <code>&lt;li&gt;</code> element, we may set marker values as in the following example:</p>
										<pre><code>&lt;ol&gt;
	&lt;li value=3&gt;The marker for this item is the number 3&lt;/li&gt;
	&lt;li&gt;The marker for this item is the number 4&lt;/li&gt;
	&lt;li&gt;The marker for this item is the number 5&lt;/li&gt;
	&lt;li value=11&gt;The marker for this item is the number 11&lt;/li&gt;
	&lt;li&gt;The marker for this item is the number 12&lt;/li&gt;
	&lt;li&gt;The marker for this item is the number 13&lt;/li&gt;
&lt;/ol&gt;</code></pre>
										<p>..which looks like this:</p>
										<ol>
										<li value=3>The marker for this item is the number 3</li>
										<li>The marker for this item is the number 4</li>
										<li>The marker for this item is the number 5</li>
										<li value=11>The marker for this item is the number 11</li>
										<li>The marker for this item is the number 12</li>
										<li>The marker for this item is the number 13</li>
										</ol>
										<p>We can do something similar by using the <code>start</code> attribute, which enables us to specify the initial value of an ordered list. Here is an example:</p>
										<pre><code>&lt;ol start=77&gt;
	&lt;li&gt;The marker for this item is the number 77&lt;/li&gt;
	&lt;li&gt;The marker for this item is the number 78&lt;/li&gt;
	&lt;li&gt;The marker for this item is the number 79&lt;/li&gt;
&lt;/ol&gt;</code></pre>
										<p>..which produces this:</p>
										<ol start=77>
										<li>The marker for this item is the number 77</li>
										<li>The marker for this item is the number 78</li>
										<li>The marker for this item is the number 79</li>
										</ol>
										<p>This seems incredibly useful, such that I wonder if there is an equivalent way to accomplish this using modern methods, <acronym title="Cascading Style Sheets">CSS</acronym> and/or <acronym title="Hypertext Markup Language">HTML</acronym>.</p>
										<p>One final trick before I close &#8212; older versions of <acronym title="Hypertext Markup Language">HTML</acronym> enable you to create &ldquo;compact&rdquo; lists using the <code>compact</code> attribute:</p>
										<pre><code>&lt;ol compact&gt;
	&lt;li&gt;Business&lt;/li&gt;
	&lt;li&gt;Pleasure&lt;/li&gt;
	&lt;li&gt;Nonsense&lt;/li&gt;
&lt;/ol&gt;</code></pre>
										<p>The idea here is that any list featuring the <code>compact</code> attribute will be displayed in a more compact fashion in the browser. Instead of applying the usual margin and padding to the list and its various items, the browser will reduce the amount of these properties to render a tighter, more &ldquo;compact&rdquo;-looking list.</p>
										<p>That does it for this fun-filled episode of <a href="http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/" title="Sexy HTML List Tricks">Sexy HTML List Tricks</a> &#8212; <a href="http://perishablepress.com/press/feed/" title="Get high-quality web-dev content delivered fresh to your reader">stay tuned</a> for more exciting content from <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/" title="Read 'Sexy HTML List Tricks' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/09/25/absolute-horizontal-and-vertical-centering-via-css/" title="Absolute Horizontal and Vertical Centering via CSS (September 25, 2007)">Absolute Horizontal and Vertical Centering via CSS</a></li>
					<li><a href="http://perishablepress.com/press/2008/09/01/multiple-loops-and-multiple-columns-with-wordpress/" title="Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS (September 1, 2008)">Multiple Loops and Multiple Columns with WordPress, (X)HTML and CSS</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/02/embed-external-content-via-iframe-and-div/" title="Embed External Content via iframe and div (January 2, 2007)">Embed External Content via iframe and div</a></li>
					<li><a href="http://perishablepress.com/press/2007/01/16/maximum-and-minimum-height-and-width-in-internet-explorer/" title="Maximum and Minimum Height and Width in Internet Explorer (January 16, 2007)">Maximum and Minimum Height and Width in Internet Explorer</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/12/prevent-javascript-elements-from-breaking-page-layout/" title="Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom (November 12, 2007)">Prevent JavaScript Elements from Breaking Page Layout when Following Yahoo Performance Tip #6: Place Scripts at the Bottom</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/19/cssxhtml-tutorial-hovering-accessibility-jump-menu/" title="CSS/(X)HTML Tutorial: Hovering Accessibility Jump Menu (March 19, 2008)">CSS/(X)HTML Tutorial: Hovering Accessibility Jump Menu</a></li>
					<li><a href="http://perishablepress.com/press/2008/09/10/series-summary-obsessive-css-code-formatting/" title="Series Summary: Obsessive CSS Code Formatting (September 10, 2008)">Series Summary: Obsessive CSS Code Formatting</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=UC3bDFMCnPs:PwmIG0XMWQ4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=UC3bDFMCnPs:PwmIG0XMWQ4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=UC3bDFMCnPs:PwmIG0XMWQ4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=UC3bDFMCnPs:PwmIG0XMWQ4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=UC3bDFMCnPs:PwmIG0XMWQ4:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/08/16/sexy-html-list-tricks/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The 5-Minute CSS Mobile Makeover</title>
		<link>http://perishablepress.com/press/2009/08/02/the-5-minute-css-mobile-makeover/</link>
		<comments>http://perishablepress.com/press/2009/08/02/the-5-minute-css-mobile-makeover/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 04:55:51 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Accessibility]]></category>

		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[browsers]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[mobile]]></category>

		<category><![CDATA[usability]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/08/02/the-5-minute-css-mobile-makeover/</guid>
		<description><![CDATA[										More people are surfing the Web via mobile device than ever before. It&#8217;s just so convenient to have that mobile access to anything you need. Sadly, most websites have not yet considered their mobile visitors, who probably move on to the next site before trying to make sense of a jumbled mess. Those of you [...]]]></description>
			<content:encoded><![CDATA[										<p>More people are surfing the Web via mobile device than ever before. It&rsquo;s just so convenient to have that mobile access to anything you need. Sadly, most websites have not yet considered their mobile visitors, who probably move on to the next site before trying to make sense of a <strong>jumbled mess</strong>. Those of you who surf the Mobile Web know exactly what I&rsquo;m talking about here: sites that &ldquo;get it&rdquo; are a <em>joy</em> to visit, but those that don&rsquo;t are a total <em>pain</em>. What&rsquo;s to get? Well, for one, if you do nothing else for your mobile visitors, take five minutes and implement a basic stylesheet to make your site readable via mobile device. This tutorial will show you how to retain visitors and reduce bounce rate with a super-easy 5-minute mobile makeover.</p>
										<h3>You think I&rsquo;m joking</h3>
										<p>Before we begin, I feel it necessary to emphasize the serious <em>need</em> for millions of mobile makeovers. There are waay tooo many sites that are completely inaccessible on the Mobile Web simply because their owners are either too lazy or ignorant to do anything about it. Think I&rsquo;m joking? For those of you who haven&rsquo;t surfed via mobile recently, allow me to share a few surprisingly borked websites:</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/mobile-styles/screenshots-01.jpg" alt="[ Mobile Screenshots: WordPress.com, About.com, Go.com ]" /><br /><small>Mobile screenshots of WordPress.com, and About.com, Go.com</small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/mobile-styles/screenshots-02.jpg" alt="[ Mobile Screenshots: Alexa.com, DailyMotion.com, MediaFire.com, Hi5.com  ]" /><br /><small>Mobile screenshots of Alexa.com, DailyMotion.com, MediaFire.com, and Hi5.com</small></p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/mobile-styles/screenshots-03.jpg" alt="[ Mobile Screenshots: Go.com, Wikipedia.com, imdb.com, Conduit.com ]" /><br /><small>Mobile screenshots of Go.com, Wikipedia.com, imdb.com, and Conduit.com</small></p>
										<p>As you can see, it&rsquo;s a bloody war zone out there. And we&rsquo;re not just talking about smaller, personal sites either &#8212; all of the screenshots shown above were taken from the top 50 sites on the Web <small>[1]</small>. Sure, some sites are still readable, but if there is a better alternative elsewhere on the Web, I&rsquo;m there. Other sites are just too terrible to even consider, and get bounced out of the browser before you can say, &ldquo;WTF?&rdquo; If this sounds like your site, or if you&rsquo;re just not sure because you&rsquo;ve never actually <em>seen</em> your site from a mobile device, it&rsquo;s time for a mobile makeover.</p>
										<h3>Mobile stylesheets to the rescue</h3>
										<p>Even if you do nothing else to fix your broken site, add an alternate stylesheet for mobile devices. Really. You don&rsquo;t even have to include any styles &#8212; the very presence of a mobile-specific stylesheet will override all styles from your screen stylesheet, thereby simplifying the presentation of your site. Including a mobile-specific stylesheet is as easy as uploading a blank <code>.css</code> file and adding the following code to the <code>&lt;head&gt;</code> of your web pages:</p>
										<pre><code>&lt;link rel="stylesheet" href="http://domain.tld/mobile.css" type="text/css" media="handheld" /&gt;</code></pre>
										<p>The key here is the <code>media="handheld"</code> attribute, which tells browsers to apply the linked stylesheet to all mobile devices. This method isn&rsquo;t perfect, especially considering the difficulty of testing on the millions of different mobile devices currently available. For example, the Windows Mobile browser will not apply <code>media="handheld"</code> stylesheets if a <code>media="screen"</code> stylesheet is also included. This is unfortunate because virtually all websites use a <code>screen</code>-media stylesheet to style their sites. Fortunately, there is a simple yet effective fix that will force Windows Mobile browsers to apply <code>handheld</code>-media stylesheets whenever available. </p>
										<p>The trick to getting Windows Mobile to recognize <code>handheld</code> stylesheets is to capitalize the <code>media</code> attribute value for the <code>screen</code> stylesheet:</p>
										<pre><code>&lt;link rel="stylesheet" href="http://domain.tld/screen.css" type="text/css" media="Screen" /&gt;
&lt;link rel="stylesheet" href="http://domain.tld/mobile.css" type="text/css" media="handheld" /&gt;</code></pre>
										<p>Notice the capital &ldquo;<code>S</code>&rdquo; in &ldquo;<code>Screen</code>&rdquo;? That&rsquo;s all it takes to get <code>handheld</code> stylesheets working in Windows Mobile browsers.</p>
										<p><strong>Take-home message for basic mobile-friendliness:</strong> clear your default browser styles by including a blank <code>handheld</code> stylesheet via the &ldquo;Capital-S Method&rdquo; described above. Then, once your site&rsquo;s presentation is reset to (mobile) browser defaults, move on to the next section for additional mobile-makeover tips.</p>
										<h3>Dinosaur protection</h3>
										<p>At this point you should be delivering at least two separate stylesheets, one for <code>screen</code> media and another for <code>handheld</code> media. So far so good, but we need to account for <strong>older browsers</strong> that may ignore the <code>handheld</code> attribute and apply the mobile styles to the page. This could have a  devastating impact on the look of your site in older browsers. To help prevent this from happening, we want to enclose any mobile-specific styles within an <code>@media</code> selector as follows:</p>
										<pre><code>@media handheld {

	.selector-01 {
		padding: 0;
		margin: 0;
		}
	.selector-02 {
		padding: 0;
		margin: 0;
		}
	.selector-03 {
		padding: 0;
		margin: 0;
		}

}</code></pre>
										<p>This is merely a precautionary measure aimed at preventing old browsers from applying your mobile styles to your normal screen styles. All <acronym title="Cascading Style Sheets">CSS</acronym> styles that are placed in your <code>handheld</code> stylesheet should be enclosed and qualified by the <code>@media</code>&nbsp;<code>handheld</code> selector.</p>
										<h3>Apply some mobile styles</h3>
										<p>Now that you&rsquo;ve got everything setup and ready to go, it&rsquo;s time to apply some sweet mobile styles to get your pages looking oh so tuff. Of course the amount of styling is entirely up to you &#8212; you design your mobile pages as elaborately or as minimally as desired. As mentioned, by merely including the mobile stylesheet, you will have effectively neutralized any full-size screen styles that you may have had in place. Thus, as you start out, you will see something similar to this:</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/mobile-styles/screenshots-05.jpg" alt="[ Screenshot: Default Mobile Browser Styles ]" /><br /><small>Default mobile browser styles on the <a href="http://perishablepress.com/press/2007/07/30/get-organized-save-time-with-att-8525-pocket-pc/" title="Get Organized, Save Time with the AT&#038;T 8525 Pocket PC">HTC 8525</a> mobile device</small></p>
										<p>As you can see, compared with the atrocious examples shown above, the simple act of including even a blank stylesheet can take your site from &ldquo;WTF!!!&rdquo; to &ldquo;FTW!!!&rdquo; in the blink of an eye.</p>
										<p>But why stop there? Sure your site displays all nice, crisp and clean on mobile devices, but there are a few basic improvements that can greatly enhance the look and feel of your mobile site. For example, mobile browsers are usually pretty tiny, so you will want to maximize every pixel of available screen space. One way of doing this involves eliminating extraneous margins and padding from around the <code>&lt;html&gt;</code> and <code>&lt;body&gt;</code> elements. Nothing too extreme, perhaps a nice 3-pixel bit of padding to give the content just enough breathing room. While we&rsquo;re at it, let&rsquo;s ensure we&rsquo;ve got a clean white background and some nicely contrasting text color:</p>
										<pre><code>html, body {
	background: #fff;
	padding: 3px;
	color: #000;
	margin: 0;
	}</code></pre>
										<p>Of course, the goal here is to get you thinking about how to customize the presentation of your site. Background colors, text colors, and even font families are all fun things to play around with. To keep things basic, we can add a simple, sans-serif font with a decent font-size and line height:</p>
										<pre><code>html, body {
	font: 12px/15px sans-serif;
	background: #fff;
	padding: 3px;
	color: #000;
	margin: 0;
	}</code></pre>
										<h3>Mind your floats please</h3>
										<p>An important thing to keep in mind as you implement a new <code>handheld</code> stylesheet is that all of the content will appear in linear order in a single column down the length of the page. Floated items such as sidebars, callouts, and other items will appear either above or below your main content, depending on the order of appearance in the source code. This is a good thing, especially considering the extremely narrow screen-widths of most mobile devices. To include a floated sidebar would require users to scroll horizontally as well as vertically. As you may know, horizontal scrolling sucks, especially when working on the go. So keep this in mind before re-floating anything in your <code>handheld</code> stylesheet. To be extra cautious, the truly paranoid can add this to their mobile styles:</p>
										<pre><code>* {
	float: none;
	}</code></pre>
										<h3>There is no width</h3>
										<p>Similar thinking applies for content width. Any explicit widths (those set in pixels or ems) that you set in your mobile stylesheet will probably do more harm than good, especially considering the extreme variation in screen widths across devices. Specifying a width for your content may result in proper display in a few devices, but there inevitably will be many more that will require horizontal scrolling to display the content. A good solution is to either specify your widths in percentages or avoid specifying widths except where required for layout purposes (e.g., for small graphics, etc.).</p>
										<h3>Eliminate clutter</h3>
										<p>Keeping things simple is one of the primary goals when designing for small screens. On a full-size web page, you&rsquo;ve got plenty of room for lots of buttons, badges, advertisements, photos, and anything else that tickles your fancy. The question you need to ask yourself is, &ldquo;how much of this content is <em>necessary</em> for my mobile visitors?&rdquo; Only you can make that decision, but there are a few questions that may help you think through the process:</p>
										<ul>
										<li>What are mobile visitors looking for? What information do they want/need?</li>
										<li>Do mobile visitors have time/interest in all of my tedious sidebar content?</li>
										<li>With a barebones stylesheet, which elements are clearly superfluous?</li>
										<li>Which navigational elements are absolutely necessary? Which are redundant?</li>
										<li>Are there entire regions of my page that would be better off not displayed?</li>
										</ul>
										<p>And so on and so forth. Hopefully you get the idea: <strong>only display what is absolutely necessary or essential</strong>. Perhaps an example will serve to illustrate the point. Here at <a href="http:perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>, I recently <a href="http://perishablepress.com/press/2007/10/29/new-mobile-css-styles-for-perishable-press/" title="New Mobile CSS Styles for Perishable Press">implemented a mobile-friendly stylesheet</a> for some of my themes. The thinking/design process went something like this:</p>
										<ul>
										<li>First, reset everything to default mobile styles.</li>
										<li>Most mobile visitors are here for one thing: content.</li>
										<li>Thus, there is no need for a sidebar or a super-footer.</li>
										<li>I decided to display a small logo, some header nav, and a small footer.</li>
										<li>Basic styles were applied to post content and comments.</li>
										<li>The result is a clean, easy-to-use mobile version of my site.</li>
										</ul>
										<p>And of course, to hide the unwanted elements, I added the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>#sidebar, #footer {
	display: none;
	}</code></pre>
										<p>Hopefully that is clear, the idea is to apply <code>display:none;</code> to the <em>outermost</em> element of the area that you would like to hide. As a noob way back in the day, I didn&rsquo;t realize this, and instead applied <code>display:none;</code> to <em>every</em> element within the hidden area. So silly&nbsp;;)</p>
										<h3>More mobile-makeover tips</h3>
										<p><strong>Slim down heading elements</strong><br />On many mobile devices (at least on the ones that I&rsquo;ve seen), heading text frequently appears to be heavily overweighted (new word), especially text within <code>&lt;h1&gt;</code> and <code>&lt;h2&gt;</code> elements. To alleviate this issue, we can add the following <acronym title="Cascading Style Sheets">CSS</acronym> to our <code>handheld</code> stylesheet:</p>
										<pre><code>h1, h2, h3, h4, h5, h6 {
	font-weight: normal;
	}</code></pre>
										<p><strong>Control your images</strong><br />Images are another element that you may want to consider. Chances are that many of your images exceed the width of most mobile browsers, which may or may not automatically resize them. Fortunately, we can apply a maximum-width to our images that will help insure their proper scaling in supportive browsers. The trick is choosing a <code>max-width</code> that accommodates the widest variety of mobile devices. As an example, here is how to apply a <code>max-width</code> of <code>250px</code> for all images in our main content <code>&lt;div&gt;</code>:</p>
										<pre><code>#content img { 
	max-width: 250px;
	}</code></pre>
										<p><strong>Front and center</strong><br />Centering headings, footer credits, and other information is a uesful way to bring a sense of organization and balance to your mobile presentation. Here is an easy way to do so:</p>
										<pre><code>.center {
	width: 100%; !important;
	text-align: center;
	}</code></pre>
										<p><strong>Link me deadly</strong><br />Last but not least, links are perhaps the most important element on the mobile page. When easily identifiable, links help visitors navigate easily and efficiently. When poorly styled or otherwise obscure, links are essentially useless, leaving your visitors groping in the dark for their next move. Thus, when styling your mobile links, it is good practice to emulate conventional link appearance with an underline, distinguished color, and perhaps a slightly contrasting background color to boot. Here is an example that keeps links looking crisp and clean:</p>
										<pre><code>a:link, a:visited {
	text-decoration: underline;
	color: #0000CC;
	}
a:hover, a:active {
	text-decoration: underline;
	color: #660066;
	}</code></pre>
										<h3>Apply styles to the iPhone</h3>
										<p>As you go about applying styles for the mobile presentation of your site, you will inevitably want to target the ubiquitous iPhone and apply a few iPhone-specific <acronym title="Cascading Style Sheets">CSS</acronym> styles. Fortunately, the iPhone has a rather unique screen width, enabling us to target specific selectors with the following <code>@media</code> selector:</p>
										<pre><code>@media only screen and (max-device-width: 480px) { 

	.selector {
		padding: 0;
		margin: 0;
		}

}</code></pre>
										<p>With this technique, you can target any elements you wish. Simply enclose your iPhone-specific <acronym title="Cascading Style Sheets">CSS</acronym> with that crazy-looking <code>@media</code> selector and enjoy the results. Note that there <em>are</em> other (non-iPhone) mobile browsers that also have the same screen width as the iPhone, so any styles targeting the iPhone may also be applied to a few other devices as well.</p>
										<p>Another useful technique for the iPhone involves controlling the automatic resizing of text. The iPhone has an annoying habit of adjusting font size according to the width of the web page. While occasionally useful, this &ldquo;feature&rdquo; has a tendency to make your web pages look like crap. Fortunately, we can override this feature with the following slice of <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>html {
	-webkit-text-size-adjust: none;
	}</code></pre>
										<p>This is a proprietary property aimed exclusively at Safari. Accepted values are as follows:</p>
										<ul>
										<li><code>none</code> &#8212; this is the default value. no text-size adjustments will be made</li>
										<li><code>auto</code> &#8212; leave it up to the Safari browser to handle any text-size adjustments</li>
										<li><code>%value</code> &#8212; specify an explicit percentage value by which to adjust text-size</li>
										</ul>
										<p>Have more sweet iPhone design tips? Share it with a comment!&nbsp;:)</p>
										<h3>Putting it all together</h3>
										<p>Let&rsquo;s put everything together to create a basic <code>handheld</code> stylesheet template. Applied to your site via separate external <code>handheld</code> stylesheet, the following code will give your site a quick 5-minute mobile makeover:</p>
										<pre><code>/* mobile styles */
@media handheld {

	html, body {
		font: 12px/15px sans-serif;
		background: #fff;
		padding: 3px;
		color: #000;
		margin: 0;
		}
	#sidebar, #footer {
		display: none;
		}
	h1, h2, h3, h4, h5, h6 {
		font-weight: normal;
		}
	#content img { 
		max-width: 250px;
		}
	.center {
		width: 100%; !important;
		text-align: center;
		}
	a:link, a:visited {
		text-decoration: underline;
		color: #0000CC;
		}
	a:hover, a:active {
		text-decoration: underline;
		color: #660066;
		}

}
/* iPhone-specific styles */
@media only screen and (max-device-width: 480px) { 

	html {
		-webkit-text-size-adjust: none;
		}

}</code></pre>
										<p>These are some of the <acronym title="Cascading Style Sheets">CSS</acronym> rules that I use for various themes here at <a href="http://perishablepress.com/" title="Perishable Press: Digital Design and Dialogue">Perishable Press</a>. After customizing a basic set of styles with some fresh link colors and a few other bits of presentational seasoning, I have transformed my complex screen designs into something crisp, clean, and easy to read for my mobile visitors:</p>
										<p><img src="http://perishablepress.com/press/wp-content/images/2009/mobile-styles/screenshots-04.jpg" alt="[ Mobile Screenshot: Perishable Press ]" /><br /><small>Mobile Screenshot of Perishable Press</small></p>
										<h3>No more excuses</h3>
										<p>With these simple steps, you can ensure that your visitors are able to access your content in a user-friendly way. You don&rsquo;t need to create a complete mobile version of your site, but adding a few basic rules will ensure that your site is available, accessible, and useful for your mobile visitors. So no more excuses! We have the technology and skills to make the mobile Web a better place. Get on board and pimp your sites for the Mobile Web today.</p>
										<p><small>[1] According to Alexa, which may or may not be the most accurate source of information.</small></p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/08/02/the-5-minute-css-mobile-makeover/" title="Read 'The 5-Minute CSS Mobile Makeover' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/10/29/new-mobile-css-styles-for-perishable-press/" title="New Mobile CSS Styles for Perishable Press (October 29, 2007)">New Mobile CSS Styles for Perishable Press</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/19/cssxhtml-tutorial-hovering-accessibility-jump-menu/" title="CSS/(X)HTML Tutorial: Hovering Accessibility Jump Menu (March 19, 2008)">CSS/(X)HTML Tutorial: Hovering Accessibility Jump Menu</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/21/a-complete-css-template-file/" title="A Complete CSS Template File (August 21, 2006)">A Complete CSS Template File</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/28/accessibility-notes-plus/" title="Accessibility Notes Plus (August 28, 2006)">Accessibility Notes Plus</a></li>
					<li><a href="http://perishablepress.com/press/2006/09/18/ie-scrollbar-colors/" title="IE Scrollbar Colors (September 18, 2006)">IE Scrollbar Colors</a></li>
					<li><a href="http://perishablepress.com/press/2006/09/18/absolutely-centered-layout/" title="Absolutely Centered Layout (September 18, 2006)">Absolutely Centered Layout</a></li>
					<li><a href="http://perishablepress.com/press/2006/12/18/automatic-language-translation-methods/" title="Automatic Language Translation Methods (December 18, 2006)">Automatic Language Translation Methods</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=XUj8bbMn-_o:7M7BfhU5iww:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=XUj8bbMn-_o:7M7BfhU5iww:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=XUj8bbMn-_o:7M7BfhU5iww:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=XUj8bbMn-_o:7M7BfhU5iww:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=XUj8bbMn-_o:7M7BfhU5iww:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/08/02/the-5-minute-css-mobile-makeover/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Power of HTML 5 and CSS 3</title>
		<link>http://perishablepress.com/press/2009/07/19/power-of-html5-css3/</link>
		<comments>http://perishablepress.com/press/2009/07/19/power-of-html5-css3/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 05:46:08 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Presentation]]></category>

		<category><![CDATA[Structure]]></category>

		<category><![CDATA[Websites]]></category>

		<category><![CDATA[code]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[design]]></category>

		<category><![CDATA[markup]]></category>

		<category><![CDATA[Standards]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/07/19/power-of-html5-css3/</guid>
		<description><![CDATA[										
										Web designers can do some pretty cool stuff with HTML&#160;4 and CSS&#160;2.1. We can structure our documents logically and create information-rich sites without relying on archaic, table-based layouts. We can style our web pages with beauty and detail without resorting to inline &#60;font&#62; and &#60;br&#62; tags. Indeed, our current design methods have taken us far [...]]]></description>
			<content:encoded><![CDATA[										<p><img src="http://perishablepress.com/press/wp-content/images/2009/misc-chunks/html-css-power.jpg" alt="[ Electrical Surge ]" /></p>
										<p>Web designers can do some pretty cool stuff with <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;4 and <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;2.1. We can structure our documents logically and create information-rich sites without relying on archaic, table-based layouts. We can style our web pages with beauty and detail without resorting to inline <code>&lt;font&gt;</code> and <code>&lt;br&gt;</code> tags. Indeed, our current design methods have taken us far beyond the hellish era of browser wars, proprietary protocols, and those hideous flashing, scrolling, and blinking web pages.</p>
										<p>As far as we&rsquo;ve come using <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;4 and <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;2.1, however, we can do better. We can refine the structure of our documents and increase their semantic precision. We can sharpen the presentation of our stylesheets and advance their stylistic flexibility. As we continue to push the boundaries of <em>existing</em> languages, <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 and <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 are quickly gaining popularity, revealing their collective power with some exciting new design possibilities.</p>
										<h3>Goodbye <code>&lt;div&gt;</code> soup, hello semantic markup</h3>
										<p>In the past, designers wrestled with semantically incorrect table-based layouts. Eventually, thanks to revolutionary thinking from the likes of <a href="http://www.zeldman.com/" title="Zeldman.com">Jeffrey Zeldman</a> and <a href="http://meyerweb.com/" title="meyerweb.com">Eric Meyer</a>, savvy designers embraced more semantically correct layout methods, structuring their pages with <code>&lt;div&gt;</code> elements instead of tables, and using external stylesheets for presentation. Unfortunately, complex designs require significant differentiation of underlying structural elements, which commonly results in the &ldquo;<code>&lt;div&gt;</code>-soup&rdquo; syndrome. Perhaps this looks familiar:</p>
										<pre><code>&lt;div id="news"&gt;
   &lt;div class="section"&gt;
      &lt;div class="article"&gt;
         &lt;div class="header"&gt;
            &lt;h1&gt;Div Soup Demonstration&lt;/h1&gt;
            &lt;p&gt;Posted on July 11th, 2009&lt;/p&gt;
         &lt;/div&gt;
         &lt;div class="content"&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
         &lt;/div&gt;
         &lt;div class="footer"&gt;
            &lt;p&gt;Tags: HMTL, code, demo&lt;/p&gt;
         &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="aside"&gt;
         &lt;div class="header"&gt;
            &lt;h1&gt;Tangential Information&lt;/h1&gt;
         &lt;/div&gt;
         &lt;div class="content"&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
         &lt;/div&gt;
         &lt;div class="footer"&gt;
            &lt;p&gt;Tags: HMTL, code, demo&lt;/p&gt;
         &lt;/div&gt;
      &lt;/div&gt;
   &lt;/div&gt;
&lt;/div&gt;</code></pre>
										<p>While slightly contrived, this example serves to illustrate the structural redundancy of designing complex layouts with <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;4 (as well as <acronym title="eXtensible Hypertext Markup Language">XHTML</acronym> 1.1 et al). Fortunately, <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 alleviates <code>&lt;div&gt;</code>-soup syndrome by giving us a new set of structural elements. These <a href="http://perishablepress.com/press/2007/08/21/rethinking-structural-design-with-new-elements-in-html-5/" title="Rethinking Structural Design with New Elements in HTML 5">new <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 elements</a> replace meaningless <code>&lt;div&gt;</code>s with more semantically accurate definitions, and in doing so provide more &ldquo;natural&rdquo; <acronym title="Cascading Style Sheets">CSS</acronym> hooks with which to style the document. With <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5, our example evolves:</p>
										<pre><code>&lt;section&gt;
   &lt;section&gt;
      &lt;article&gt;
         &lt;header&gt;
            &lt;h1&gt;Div Soup Demonstration&lt;/h1&gt;
            &lt;p&gt;Posted on July 11th, 2009&lt;/p&gt;
         &lt;/header&gt;
         &lt;section&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
         &lt;/section&gt;
         &lt;footer&gt;
            &lt;p&gt;Tags: HMTL, code, demo&lt;/p&gt;
         &lt;/footer&gt;
      &lt;/article&gt;
      &lt;aside&gt;
         &lt;header&gt;
            &lt;h1&gt;Tangential Information&lt;/h1&gt;
         &lt;/header&gt;
         &lt;section&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
            &lt;p&gt;Lorem ipsum text blah blah blah.&lt;/p&gt;
         &lt;/section&gt;
         &lt;footer&gt;
            &lt;p&gt;Tags: HMTL, code, demo&lt;/p&gt;
         &lt;/footer&gt;
      &lt;/aside&gt;
   &lt;/section&gt;
&lt;/section&gt;</code></pre>
										<p>As you can see, <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 enables us to replace our multitude of <code>&lt;div&gt;</code>s with semantically meaningful structural elements. This semantic specificity not only improves the underlying quality and meaningfulness of our web pages, but also enables us to remove many of the <code>class</code> and <code>id</code> attributes that were previously required for targeting our <acronym title="Cascading Style Sheets">CSS</acronym>. In fact, <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 makes it possible to eliminate virtually all <code>class</code> and <code>id</code> attributes.</p>
										<h3>Goodbye <code>class</code> attributes, hello clean markup</h3>
										<p>When combined with the new semantic elements of <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5, <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 provides web designers with god-like powers over their web pages. With the power of <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5, we obtain significantly more control over the <em>structure</em> of our documents, and with the power of <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3, our control over the <em>presentation</em> of our documents tends toward infinity. </p>
										<p>Even without some of the advanced <acronym title="Cascading Style Sheets">CSS</acronym> selectors available to us, the new variety of specific <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 elements enable us to apply styles across similar sections <em>without</em> the need for defining <code>class</code> and <code>id</code> attributes. To style our previous <code>&lt;div&gt;</code>-soup example, we would target the multitude of attributes via the following <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>div#news    {}
div.section {}
div.article {}
div.header  {}
div.content {}
div.footer  {}
div.aside   {}</code></pre>
										<p>On the other hand, to style our <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 example, we may target the various documents regions directly with this <acronym title="Cascading Style Sheets">CSS</acronym>:</p>
										<pre><code>section {}
article {}
header  {}
footer  {}
aside   {}</code></pre>
										<p>This is an improvement, but there are several issues that need addressed. With the <code>&lt;div&gt;</code> example, we target each area specifically through use of <code>class</code> and <code>id</code> attributes. Using this logic allows us to apply styles to each region of the document, either collectively or individually. For example, in the <code>&lt;div&gt;</code> case, <code>.section</code> and <code>.content</code> divisions are easily distinguished; however, in the <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 case, the <code>section</code> element is used for both of these areas and others as well. This is easily resolved by adding specific attribute selectors to the different <code>section</code> elements, but thankfully, we instead may use a few advanced <acronym title="Cascading Style Sheets">CSS</acronym> selectors to target the different <code>section</code> elements in obtrusive fashion.</p>
										<h3>Targeting HTML-5 elements without classes or ids</h3>
										<p>Rounding out the article, let&rsquo;s look at some practical examples of targeting <acronym title="Hypertext Markup Language">HTML</acronym>-5 elements without <code>class</code>es or <code>id</code>s. There are three types of <acronym title="Cascading Style Sheets">CSS</acronym> selectors that will enable us to target and differentiate the elements in our example. They are as follows:</p>
										<ul>
										<li>The descendant selector <small>[CSS 2.1]</small>: <strong>E F</strong></li>
										<li>The adjacent selector <small>[CSS 2.1]</small>: <strong>E + F</strong></li>
										<li>The child selector <small>[CSS 2.1]</small>: <strong>E > F</strong></li>
										</ul>
										<p>Let&rsquo;s have a look at how these selectors enable us to target each of our document sections without the need for <code>class</code>es or <code>id</code>s.</p>
										<p><strong>Targeting the outermost <code>&lt;section&gt;</code> element</strong><br />Due to the incompleteness of our example, we will assume that the outermost <code>&lt;section&gt;</code> element is <em>adjacent</em> to a <code>&lt;nav&gt;</code> element which itself is a direct descendant of the <code>&lt;body&gt;</code> element. In this case, we may target the outermost <code>&lt;section&gt;</code> as follows:</p>
										<pre><code>body nav+section {}</code></pre>
										<p><strong>Targeting the next <code>&lt;section&gt;</code> element</strong><br />As the only direct descendant of the outer <code>&lt;section&gt;</code>, the next <code>&lt;section&gt;</code> element may be specifically targeted with the following selector:</p>
										<pre><code>section&gt;section {}</code></pre>
										<p><strong>Targeting the <code>&lt;article&gt;</code> element</strong><br />There are several ways to target the <code>&lt;article&gt;</code> element specifically, but the easiest is to use a simple descendant selector:</p>
										<pre><code>section section article {}</code></pre>
										<p><strong>Targeting the <code>header</code>, <code>section</code>, and <code>footer</code> elements</strong><br />In our example, each of these three elements exists in two locations: once inside the <code>&lt;article&gt;</code> element and once inside the <code>&lt;aside&gt;</code> element. This distinction makes it easy to target each element individually:</p>
										<pre><code>article header {}
article section {}
article footer {}</code></pre>
										<p>..or collectively:</p>
										<pre><code>section section header {}
section section section {}
section section footer {}</code></pre>
										<p>So far, we have managed to eliminate all <code>class</code>es and <code>id</code>s using only <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;2.1. So why do we even need anything from <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3? I&rsquo;m glad you asked..</p>
										<h3>Advanced targeting of HTML 5 with CSS 3</h3>
										<p>While we have managed to target every element in our example using only valid <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;2.1, there are obviously more complicated situations where the more advanced selective power of <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 is required. Let&rsquo;s wrap things up with a few specific examples showing how <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 enables us to style any element <em>without</em> extraneous <code>class</code> or <code>id</code> attributes.</p>
										<p><strong>Targeting all posts with a unique post ID</strong><br />WordPress provides us a way of including the ID of each post in the source-code output. This information is generally used for navigational and/or informational purposes, but with <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 we can use these existing yet unique ID attributes as a way to select the posts for styling. Sure, you could always just add a <code>class="post"</code> attribute to every post, but that would defeat the point of this exercise (plus it&rsquo;s no fun). By using the &ldquo;substring matching attribute selector,&rdquo; we can target all posts and their various elements like this:</p>
										<pre><code>article[id*=post-] {}           /* target all posts */
article[id*=post-] header h1 {} /* target all post h1 tags */
article[id*=post-] section p {} /* target all post p tags */</code></pre>
										<p>Now that&rsquo;s just sick, and we can do the same thing for numerically identified comments, enabling us to apply targeted styles to associated constructs:</p>
										<pre><code>article[id*=comment-] {}           /* target all comments */
article[id*=comment-] header h1 {} /* target all comment h1 tags */
article[id*=comment-] section p {} /* target all comment p tags */</code></pre>
										<p><strong>Target any specific section or article</strong><br />Many sites display numerous of posts and comments. With <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5, the markup for these items consists of repetitive series of <code>&lt;section&gt;</code> or <code>&lt;article&gt;</code> elements. To target <em>specific</em> <code>&lt;section&gt;</code> or <code>&lt;article&gt;</code> elements, we turn to the incredible power of the &ldquo;<code>:nth-child</code>&rdquo; selector:</p>
										<pre><code>section:nth-child(1) {} /* select the first &lt;section&gt; */
article:nth-child(1) {} /* select the first &lt;article&gt; */

section:nth-child(2) {} /* select the second &lt;section&gt; */
article:nth-child(2) {} /* select the second &lt;article&gt; */</code></pre>
										<p>In a similar manner, we may also target specific elements in <em>reverse</em> order via the &ldquo;<code>:nth-last-child</code>&rdquo; selector:</p>
										<pre><code>section:nth-last-child(1) {} /* select the last &lt;section&gt; */
article:nth-last-child(1) {} /* select the last &lt;article&gt; */

section:nth-last-child(2) {} /* select the penultimate &lt;section&gt; */
article:nth-last-child(2) {} /* select the penultimate &lt;article&gt; */</code></pre>
										<p><strong>More ways to select specific elements</strong><br />Another way to select specific instances of <acronym title="Hypertext Markup Language">HTML</acronym>-5 elements such as <code>&lt;header&gt;</code>, <code>&lt;section&gt;</code>, and <code>&lt;footer&gt;</code>, is to take advantage of the &ldquo;<code>:only-of-type</code>&rdquo; selector. With these <acronym title="Hypertext Markup Language">HTML</acronym>-5 elements appearing in multiple locations in the web document, it may be useful to target elements that appear only once within a particular parent element. For example, to select only <code>&lt;section&gt;</code> elements that are the only <code>&lt;section&gt;</code> elements within another <code>&lt;section&gt;</code> element (insane, I know), as in the following markup:</p>
										<pre><code>&lt;section&gt;
   &lt;section&gt;&lt;/section&gt;
   &lt;section&gt;
      &lt;section&gt;Target this section&lt;/section&gt;
   &lt;/section&gt;
   &lt;section&gt;
      &lt;section&gt;Target this section&lt;/section&gt;
   &lt;/section&gt;
   &lt;section&gt;
      &lt;section&gt;But not this section&lt;/section&gt;
      &lt;section&gt;And not this section&lt;/section&gt;
   &lt;/section&gt;
   &lt;section&gt;&lt;/section&gt;
&lt;/section&gt;</code></pre>
										<p>..we could simply use the following selector:</p>
										<pre><code>section&gt;section:only-of-type {}</code></pre>
										<p>Again, you could always add an <code>id</code> to the target element, but you would lose the increased scalability, maintainablity, and clarity made possible with an absolute separation of structure and presentation. </p>
										<p>The take-home message for these examples is that <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3 makes it possible to target virtually any <acronym title="Hypertext Markup Language">HTML</acronym>-5 element <em>without</em> littering the document with superfluous presentational attributes.</p>
										<h3>Much more to come</h3>
										<p>With the inevitable, exponential rise in popularity of both <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 and <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3, designers can look forward to many new and exciting possibilities for their web pages, applications, and scripts. Combined, these two emerging languages provide designers with immense power over the structure and presentation of their web documents. In my next article on this topic, we will explore some of the controversial aspects of <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 and also examine some of the finer nuances of <acronym title="Cascading Style Sheets">CSS</acronym>&nbsp;3. <a href="http://perishablepress.com/press/feed/" title="You should subscribe to Perishable Press. Really.">Stay tuned</a>!</p>
										<h3>Note to WordPress users</h3>
										<p>You can start using <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5 <em>right&nbsp;now</em>. To see a live, working example of a WordPress theme built entirely with <acronym title="Hypertext Markup Language">HTML</acronym>&nbsp;5, <acronym title="Cascading Style Sheets">CSS</acronym>, and of course <acronym title="PHP: Hypertext Preprocessor">PHP</acronym>, drop by the <a href="http://diggingintowordpress.com/" title="Digging into WordPress">Digging into WordPress</a> site and visit our newly revamped <a href="http://diggingintowordpress.com/ThemePlayground/" title="DiW Theme Playground">Theme Playground</a>. There you will find my recently released <a href="http://diggingintowordpress.com/ThemePlayground/index.php?wptheme=H5%20Theme%20Template" title="Live Demo of the H5 Theme Template">H5 WordPress Theme Template</a> available for immediate download. And while you&rsquo;re there, be sure to <a href="http://diggingintowordpress.com/preorder/" title="Preorder Digging into WordPress">secure your copy</a> of <em>Digging into WordPress</em>, coming this Fall.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/07/19/power-of-html5-css3/" title="Read 'The Power of HTML 5 and CSS 3' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/08/21/rethinking-structural-design-with-new-elements-in-html-5/" title="Rethinking Structural Design with New Elements in HTML 5 (August 21, 2007)">Rethinking Structural Design with New Elements in HTML 5</a></li>
					<li><a href="http://perishablepress.com/press/2007/09/25/absolute-horizontal-and-vertical-centering-via-css/" title="Absolute Horizontal and Vertical Centering via CSS (September 25, 2007)">Absolute Horizontal and Vertical Centering via CSS</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/16/xhmtlcss-remix-creative-commons-license-pages/" title="XHMTL/CSS Remix: Creative Commons License (March 16, 2008)">XHMTL/CSS Remix: Creative Commons License</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/19/cssxhtml-tutorial-hovering-accessibility-jump-menu/" title="CSS/(X)HTML Tutorial: Hovering Accessibility Jump Menu (March 19, 2008)">CSS/(X)HTML Tutorial: Hovering Accessibility Jump Menu</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/15/does-google-hate-web-standards/" title="Does Google Hate Web Standards? (June 15, 2008)">Does Google Hate Web Standards?</a></li>
					<li><a href="http://perishablepress.com/press/2006/08/21/a-complete-css-template-file/" title="A Complete CSS Template File (August 21, 2006)">A Complete CSS Template File</a></li>
					<li><a href="http://perishablepress.com/press/2006/09/18/absolutely-centered-layout/" title="Absolutely Centered Layout (September 18, 2006)">Absolutely Centered Layout</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=rMZ67LgH6Nw:1UUg_XWRClw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=rMZ67LgH6Nw:1UUg_XWRClw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=rMZ67LgH6Nw:1UUg_XWRClw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=rMZ67LgH6Nw:1UUg_XWRClw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=rMZ67LgH6Nw:1UUg_XWRClw:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/07/19/power-of-html5-css3/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Display Random Posts from Specific Tags or Categories</title>
		<link>http://perishablepress.com/press/2009/07/13/display-random-posts-from-specific-tags-or-categories/</link>
		<comments>http://perishablepress.com/press/2009/07/13/display-random-posts-from-specific-tags-or-categories/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 05:59:15 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[WordPress]]></category>

		<category><![CDATA[loops]]></category>

		<category><![CDATA[plugins]]></category>

		<category><![CDATA[tips]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/07/13/display-random-posts-from-specific-tags-or-categories/</guid>
		<description><![CDATA[										When developing the colorful Quintessential Theme (opens in new tab), I initially planned on displaying five random posts from each of my most popular tags and categories in the super-slick sliding-panel sidebar. Because I am running an older version of WordPress, however, this task proved to be quite the educational experience.
										In newer versions (from 2.5 [...]]]></description>
			<content:encoded><![CDATA[										<p>When developing the colorful <a href="http://perishablepress.com/press/index.php?wptheme=Quintessential" title="Skin the site with the 'Quintessential Theme' (opens in new tab or window)">Quintessential Theme</a> (opens in new tab), I initially planned on displaying five random posts from each of my most popular tags and categories in the super-slick sliding-panel sidebar. Because I am running an older version of WordPress, however, this task proved to be quite the educational experience.</p>
										<p>In newer versions (from 2.5 I think) of WordPress, the <code>query_posts()</code> function enables users to display posts in random order using the <code>orderby=rand</code> parameter. This would have made my life easy, as I could have included the following code for each of my random post lists:</p>
										<pre><code>&lt;ul class="random-posts"&gt;
	&lt;?php query_posts('tag=whatever&amp;showposts=5&amp;offset=0&amp;orderby=rand'); ?&gt;
	&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	&lt;li&gt;
		&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
	&lt;/li&gt;
	&lt;?php endwhile; endif; ?&gt;
&lt;/ul&gt;</code></pre>
										<p>This would have been great, but the random-post ordering doesn&rsquo;t work for my particular version of WordPress. As it turns out, for older versions of WordPress that are missing the incredibly useful <code>orderby=rand</code> parameter for the <code>query_posts()</code> function, there is an unofficial plugin available in the <a href="http://wordpress.org/support/topic/70359#post-444323" title="Display Random Posts from Specific Categories">WordPress Help Forums</a> that imparts the <code>orderby=rand</code> functionality to the <code>query_posts()</code> function, thereby enabling users of pre-2.5 versions of WordPress to implement their own random post loops.</p>
										<p>For those of you who would like to setup some random post loops on your own site, here&rsquo;s <strong>how to do it in two easy steps</strong>. (Remember, this is only necessary if the above method does not work for your particular version of WordPress.)</p>
										<h3>Numero Uno: Upload and activate the plugin</h3>
										<p>Copy &amp; paste the following code into a file named &ldquo;<code>random-posts.php</code>&rdquo; (or whatever), upload it to your <code>/wp-plugins/</code> directory, and activate it via the Plugins panel in the WordPress Admin:</p>
										<pre><code>&lt;?php
/*
Plugin Name: Random Posts Query
Description: Imparts random display functionality to posts generated via 
query_posts in older versions of WordPress (especially great for version 2.3)
Author URI: http://wordpress.org/support/topic/70359?replies=3#post-444323
*/

// usage: include "random=true" as a parameter in your query_posts loop

function query_random_posts($query) {
	return query_posts($query . '&amp;random=true');
}
class RandomPosts {
	function orderby($orderby) {
		if (get_query_var('random') == 'true')
			return "RAND()";
		else
			return $orderby;
		}
		function register_query_var($vars) {
			$vars[] = 'random';
			return $vars;
		}
}
add_filter('posts_orderby', array('RandomPosts', 'orderby'));
add_filter('query_vars', array('RandomPosts', 'register_query_var'));
?&gt;</code></pre>
										<h3>Numero Dos: Include and customize the template code</h3>
										<p>Once the plugin is in place, create multiple tag-specific and category-specific random-post lists by placing the following code <strong>after</strong> the main loop in your theme template file (e.g., the <code>sidebar.php</code> file):</p>
										<pre><code>&lt;ul class="random-posts"&gt;
	&lt;?php // use tag=whatever or category_name=whatever for cat/tag-specific posts ?&gt;
	&lt;?php query_posts('tag=whatever&amp;showposts=5&amp;offset=0&amp;random=true'); ?&gt;
	&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
	&lt;li&gt;
		&lt;a href="&lt;?php the_permalink(); ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
	&lt;/li&gt;
	&lt;?php endwhile; endif; ?&gt;
&lt;/ul&gt;</code></pre>
										<p>Before uploading, make sure you customize this code according to your needs. Old heads feel free to knock the boots, while newer chaps may benefit from the following information:</p>
										<ul>
										<li>As mentioned in the code comments, replace the &ldquo;<code>tag=whatever</code>&rdquo; parameter with the name of the tag for which you would like to display random posts.</li>
										<li>To display random posts from a specific category instead of a specific tag, simply replace the <code>tag=whatever</code> parameter with <code>category_name=whatever</code> and change the name to your chosen category.</li>
										<li>Adjust the other <code>query_posts</code> parameters as needed to accomplish your post-display goals. For example, you may also want to display the post excerpt for each post item by including the <code>the_excerpt()</code> tag.</li>
										<li>Note that this code is essentially the same as that given for newer versions of WordPress; the only difference being that you use the <code>orderby=rand</code> parameter for newer versions of WordPress (where the plugin is not required), and <code>random=true</code> for older versions (where the plugin is required).</li>
										<li>Placing additional <code>query_posts()</code> loops <em>after</em> the main loop may result in unintended paging and/or plugin issues, so make sure to place it <em>after</em> the main loop.</li>
										<li>To create multiple lists of random posts, simply create multiple instance of this loop and change the category or tag parameter names to suit your needs.</li>
										</ul>
										<h3>Time to chill</h3>
										<p>That concludes this brief retro-tutorial. Although it may not be of much use to those treading the perpetual &ldquo;upgrade&rdquo; treadmill, it will hopefully provide some relief for randomizing posts in older WordPress versions.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/07/13/display-random-posts-from-specific-tags-or-categories/" title="Read 'Display Random Posts from Specific Tags or Categories' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2006/11/20/add-rss-feed-link-icons/" title="Add RSS Feed Link Icons to WordPress Category Listings (November 20, 2006)">Add RSS Feed Link Icons to WordPress Category Listings</a></li>
					<li><a href="http://perishablepress.com/press/2007/08/06/super-loop-exclude-specific-categories-and-display-any-number-of-posts/" title="Super Loop: Exclude Specific Categories and Display any Number of Posts (August 6, 2007)">Super Loop: Exclude Specific Categories and Display any Number of Posts</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/14/easily-adaptable-wordpress-loop-templates/" title="Easily Adaptable WordPress Loop Templates (November 14, 2007)">Easily Adaptable WordPress Loop Templates</a></li>
					<li><a href="http://perishablepress.com/press/2008/02/13/transfer-autometa-plugin-data-into-all-in-one-seo-pack/" title="Transfer Autometa Plugin Data into All in One SEO Pack (February 13, 2008)">Transfer Autometa Plugin Data into All in One SEO Pack</a></li>
					<li><a href="http://perishablepress.com/press/2008/02/18/quickly-disable-or-enable-all-wordpress-plugins-via-the-database/" title="Quickly Disable or Enable All WordPress Plugins via the Database (February 18, 2008)">Quickly Disable or Enable All WordPress Plugins via the Database</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/10/wordpress-tip-remove-spam-from-the-comment-subscription-manager/" title="WordPress Tip: Remove Spam from the Comment Subscription Manager (March 10, 2008)">WordPress Tip: Remove Spam from the Comment Subscription Manager</a></li>
					<li><a href="http://perishablepress.com/press/2008/06/11/3-ways-to-exclude-content-from-wordpress-feeds/" title="3 Ways to Exclude Content from WordPress Feeds (June 11, 2008)">3 Ways to Exclude Content from WordPress Feeds</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5seby_tbWm8:UzmFp0QlszI:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5seby_tbWm8:UzmFp0QlszI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5seby_tbWm8:UzmFp0QlszI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=5seby_tbWm8:UzmFp0QlszI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=5seby_tbWm8:UzmFp0QlszI:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/07/13/display-random-posts-from-specific-tags-or-categories/feed/</wfw:commentRss>
		</item>
		<item>
		<title>HTAccess Password-Protection Tricks</title>
		<link>http://perishablepress.com/press/2009/07/13/htaccess-password-protection-tricks/</link>
		<comments>http://perishablepress.com/press/2009/07/13/htaccess-password-protection-tricks/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 15:00:22 +0000</pubDate>
		<dc:creator>Jeff Starr</dc:creator>
		
		<category><![CDATA[Function]]></category>

		<category><![CDATA[apache]]></category>

		<category><![CDATA[htaccess]]></category>

		<category><![CDATA[security]]></category>

		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://perishablepress.com/press/2009/07/13/htaccess-password-protection-tricks/</guid>
		<description><![CDATA[										Recently a reader asked about how to password-protect a directory for every specified IP while allowing open access to everyone else. In my article, Stupid htaccess Tricks, I show how to password-protect a directory for every IP except the one specified, but not for the reverse case. In this article, I will demonstrate this technique [...]]]></description>
			<content:encoded><![CDATA[										<p>Recently a reader asked about how to password-protect a directory for every specified <acronym title="Internet Protocol">IP</acronym> while allowing open access to everyone else. In my article, <a href="http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/" title="Stupid htaccess Tricks">Stupid htaccess Tricks</a>, I show how to password-protect a directory for every <acronym title="Internet Protocol">IP</acronym> except the one specified, but not for the reverse case. In this article, I will demonstrate this technique along with a wide variety of other useful password-protection tricks, including a few from my Stupid htaccess Tricks article. Before getting into the juicy stuff, we&rsquo;ll review a few basics of <acronym title="Hypertext Access">HTAccess</acronym> password protection.</p>
										<h3>HTAccess password protection works in cascading fashion</h3>
										<p>Before we begin, there are few things you need to know about Apache&rsquo;s various password-protection directives. First, these password-protection tricks apply to the directory in which they are placed. For example, to password-protect your entire site, you would place one of these tricks in the web-accessible root <acronym title="Hypertext Access">HTAccess</acronym> file for your site. <acronym title="Hypertext Access">HTAccess</acronym> directives are applied down the directory structure, in cascading fashion, such that all subdirectories are also protected.</p>
										<h3>You need two files for password protection: htaccess and htpasswd</h3>
										<p>The second thing you need to know is that, in most cases, there are two parts to any password-protection implementation: the <code>.</code><code>htaccess</code> file and the <code>.</code><code>htpasswd</code> file. The <code>.</code><code>htaccess</code> file will contain any of the sweet tricks provided in this article, while the <code>.</code><code>htpasswd</code> file will contain the required username and an encrypted version of your password.</p>
										<p>There are several ways to generate your <code>.</code><code>htpasswd</code> file. If you are comfortable with Unix, you can simply run the &ldquo;<code>htpasswd</code>&rdquo; command. For example, entering the following command will create a working password file in the <code>/home/path/</code> directory:</p>
										<p><code>htpasswd -bc /home/path/.htpasswd username password</code></p>
										<p>Placing the password file above the web-accessible root directory is a good security measure. If you examine the file after it has been created, the only thing it will contain is a line that looks similar to this:</p>
										<p><code>username:Mx1lbGn.nkP8</code></p>
										<p>Instead of running a Unix command, you may prefer to use one of the 200,000 online services providing an <a href="http://www.google.com/#hl=en&#038;q=htaccess+password+generator" title="Google Search: 'online password generator'">online password generator</a>.</p>
										<p>Regardless of how or where you decide to create your <code>.</code><code>htpasswd</code> file, keep its location in mind for use in its associated <acronym title="Hypertext Access">HTAccess</acronym> file(s). And yes, you may use one <code>.</code><code>htpasswd</code> file for multiple <acronym title="Hypertext Access">HTAccess</acronym> files placed in multiple directories.</p>
										<h3>Know which version of Apache you are using</h3>
										<p>In each of the examples below, the directives are enclosed within an <code>&lt;IfModule&gt;</code> container. This is to prevent your server from crashing if the required Apache modules are not available or not installed. Generally, the required modules will be present, but the <code>&lt;IfModule&gt;</code> check is a good precautionary measure.</p>
										<p>When implementing any of the password-protection methods in this article, make sure you double-check which version of Apache you are using before you begin. The examples in this article assume you are using either Apache 1.3 or 2.0, as the <code>&lt;IfModule&gt;</code> containers are checking for the presence of the <code>mod_auth</code> module. Thus, if you are running Apache 2.2 (or better), you will want to replace the current <code>&lt;IfModule&gt;</code> containers with the following:</p>
										<p><code>&lt;IfModule mod_authn_file.c&gt;&lt;/IfModule&gt;</code></p>
										<p>If in doubt, ask your host, install the ShowIP Firefox extension, or dig around in your server&rsquo;s control panel. And, if you just don&rsquo;t know, don&rsquo;t care, or can&rsquo;t figure it out, just remove the opening and closing <code>&lt;IfModule&gt;</code> tags from the method you would like to use and call it good. Without them, if your server is not equipped the required module, it will simply return a 500 error message, which is easily resolved by removing the password directives.</p>
										<h3>You can customize the dialogue on the password prompt</h3>
										<p>The last thing that you should know before diving into some sweet tricks is that you may customize the message shown on the password prompt by editing the following line in each of the examples in this article:</p>
										<p><code>AuthName "Username and password required"</code></p>
										<p>By changing the text inside of the quotes, you may use any language you wish for the password prompt.</p>
										<p>At this point, we&rsquo;re ready to dive into some juicy <acronym title="Hypertext Access">HTAccess</acronym> password-protection tricks!</p>
										<h3>Basic password protection</h3>
										<p>To password protect your site or any directory, place this code in the associated <acronym title="Hypertext Access">HTAccess</acronym> file:</p>
										<pre><code># basic password protection
&lt;IfModule mod_auth.c&gt;
 AuthUserFile /home/path/.htpasswd
 AuthName "Username and password required"
 AuthType Basic
 &lt;Limit GET POST&gt;
  Require valid-user
 &lt;/Limit&gt;
&lt;/IfModule&gt;</code></pre>
										<p>That&rsquo;s about as basic as it gets. Remember to create your password file and specify its directory in the first line. Let&rsquo;s move on to something more interesting.</p>
										<h3>Open-access for a single IP, password-protect for everyone else</h3>
										<p>This method is great during project development, where you want open access with the ability to give others access via password:</p>
										<pre><code># password protect excluding specific ip
&lt;IfModule mod_auth.c&gt;
 AuthName "Username and password required"
 AuthUserFile /home/path/.htpasswd
 AuthType Basic
 Require valid-user
 Order Deny,Allow
 Deny from all
 Allow from 111.222.333.444
 Satisfy Any
&lt;/IfModule&gt;</code></pre>
										<p>By placing that code into the <acronym title="Hypertext Access">HTAccess</acronym> file of the directory that you would like to protect, only the specified <acronym title="Internet Protocol">IP</acronym> will be allowed open access; everyone else will need to enter the proper username and password.</p>
										<h3>Open access for multiple IPs, password-protect for everyone else</h3>
										<p>The above code may be modified easily to provide multiple <acronym title="Internet Protocol">IP</acronym>s open access while denying everyone else:</p>
										<pre><code># password protect excluding specific ips
&lt;IfModule mod_auth.c&gt;
 AuthName "Username and password required"
 AuthUserFile /home/path/.htpasswd
 AuthType Basic
 Require valid-user
 Order Deny,Allow
 Deny from all
 Allow from localhost
 Allow from 111.222.333.444
 Allow from 555.666.777.888
 Satisfy Any
&lt;/IfModule&gt;</code></pre>
										<p>You may add as many <acronym title="Internet Protocol">IP</acronym>s as needed. This method is great during project development, where the following conditions will apply:</p>
										<ul>
										<li>Project development remains private for regular visitors</li>
										<li>Project access may be granted to clients (or anyone) by providing the password</li>
										<li>Members of the development team have open access on their respective machines</li>
										</ul>
										<p>In addition to providing unrestricted access to your team, you may also want to keep certain web services in mind by including the following directives (insert above the <code>Satisfy Any</code> directive):</p>
										<p><code>Allow from validator.w3.org</code><br />
<code>Allow from jigsaw.w3.org</code><br />
<code>Allow from google.com</code></p>
										<h3 id="custom">Open access for everyone with password-protect for specific IPs</h3>
										<p>This method is useful for a variety of situations, including cases where you would like to block a list of malicious <acronym title="Internet Protocol">IP</acronym>s. </p>
										<pre><code># password protect only for specified ips
&lt;IfModule mod_auth.c&gt;
 AuthName "Username and password required"
 AuthUserFile /home/path/.htpasswd
 AuthType Basic
 Require valid-user
 Order Allow,Deny
 Allow from all
 Deny from 111.222.333.444
 Deny from 555.666.777.888
 Satisfy Any
&lt;/IfModule&gt;</code></pre>
										<p>You may list as many <acronym title="Internet Protocol">IP</acronym> addresses as necessary. You may also deny from entire <acronym title="Internet Protocol">IP</acronym> blocks by truncating the address accordingly. For example, to block everyone coming from an <acronym title="Internet Protocol">IP</acronym> address beginning with &ldquo;<code>999.888</code>&rdquo;, we would add the following directive:</p>
										<p><code>Deny from 999.888</code></p>
										<p>For more information on how this works, see <a href="http://perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/#sec7a" title="Prevent or allow domain access for a specified range of IP addresses">this section</a> of my Stupid htaccess Tricks article.</p>
										<h3>Open access for everyone with password-protect for specific CIDR number</h3>
										<p>Similar to the previous method, here is a technique for requiring a password only from a select <acronym title="Classless Inter-Domain Routing">CIDR</acronym> number. This method is useful for blocking mega-spammers such as RIPE, Optinet, and others. If, for example, you find yourself adding line after line of Apache <code>Deny</code> directives for addresses beginning with the same first few numbers, choose one of them and try a <a href="http://www.whois.net/" title="whois lookup">whois lookup</a>. Listed within the whois results will be the <acronym title="Classless Inter-Domain Routing">CIDR</acronym> value representing every <acronym title="Internet Protocol">IP</acronym> address associated with that particular network. Thus, blocking via <acronym title="Classless Inter-Domain Routing">CIDR</acronym> is an effective way to eloquently prevent all <acronym title="Internet Protocol">IP</acronym> instances of the offender from accessing your site. Here is a generalized example for blocking by <acronym title="Classless Inter-Domain Routing">CIDR</acronym>:</p>
										<pre><code># password protect only for specified CIDR
&lt;IfModule mod_auth.c&gt;
 AuthName "Username and password required"
 AuthUserFile /home/path/.htpasswd
 AuthType Basic
 Require valid-user
 Order Allow,Deny
 Allow from all
 Deny from 10.1.0.0/16
 Deny from 80.0.0/8
 Satisfy Any
&lt;/IfModule&gt;</code></pre>
										<h3>Password protect a single file</h3>
										<p>I have used this technique countless times. To password-protect a single file, simply add this to your <acronym title="Hypertext Access">HTAccess</acronym> file:</p>
										<pre><code># password protect single file
&lt;IfModule mod_auth.c&gt;
 &lt;Files "protected.html"&gt;
  AuthName "Username and password required"
  AuthUserFile /home/path/.htpasswd
  Require valid-user
  AuthType Basic
 &lt;/Files&gt;
&lt;/IfModule&gt;</code></pre>
										<p>Here we are protecting a file named &ldquo;<code>protected.html</code>&rdquo; from access. The file will only be available after submission of the proper username and password.</p>
										<h3>Password protect multiple files</h3>
										<p>To protect multiple files, the method is very similar, only this time we are using Apache&rsquo;s <code>FilesMatch</code> directive. This allows us to list as many files as needed:</p>
										<pre><code># password protect mulitple files
&lt;IfModule mod_auth.c&gt;
 &lt;FilesMatch "(protected\.html)|(passwords\.txt)"&gt;
  AuthName "Username and password required"
  AuthUserFile /home/path/.htpasswd
  Require valid-user
  AuthType Basic
 &lt;/FilesMatch&gt;
&lt;/IfModule&gt;</code></pre>
										<p>In this example, we are password protecting two files, &ldquo;<code>protected.html</code>&rdquo; and &ldquo;<code>passwords.txt</code>&rdquo;. To add more, simply include more instances of &ldquo;<code>|(filename\.ext)</code>&rdquo; in the list of files.</p>
										<h3>Password protect multiple file types</h3>
										<p>With this method, we are using Apache&rsquo;s <code>FilesMatch</code> directive to password-protect multiple file types. Here is an example:</p>
										<pre><code># password protect mulitple file types
&lt;IfModule mod_auth.c&gt;
 &lt;FilesMatch "\.(inc|txt|log|dat|zip|rar)$"&gt;
  AuthName "Username and password required"
  AuthUserFile /home/path/.htpasswd
  Require valid-user
  AuthType Basic
 &lt;/FilesMatch&gt;
&lt;/IfModule&gt;</code></pre>
										<p>Once in place, this code will require a password for access to the following file types: <code>.inc</code>, <code>.txt</code>, <code>.log</code>, <code>.dat</code>, <code>.zip</code>, and <code>.rar</code>. Customize to suit your needs.</p>
										<h3>Password protection for everything except a single file</h3>
										<p>Thanks to <a href="http://brett.batie.com/software-development/password-protect-all-but-one-file-htaccess/" title="Brett Batie">Brett Batie</a> for this powerful technique for allowing access to a single file while password-protecting everything else:</p>
										<pre><code># password protect everything except a single file
&lt;IfModule mod_auth.c&gt;
 AuthName "Username and password required"
 AuthUserFile /home/path/.htpasswd
 Require valid-user
 AuthType Basic
 &lt;Files "open-access.html"&gt;
  Order Deny,Allow
  Deny from all
  Allow from 123.456.789
  Satisfy any
 &lt;/Files&gt;
&lt;/IfModule&gt;</code></pre>
										<p>When placed in the root directory or any parent directory, this code will password-protect everything except the file named &ldquo;<code>open-access.html</code>&rdquo;, which itself may be located in any subsequent directory or subdirectory. </p>
										<p>To protect everything while allowing access to multiple files, we may use Apache&rsquo;s <code>FilesMatch</code> directive instead. Here is an example allowing access to &ldquo;<code>open-access-1.html</code>&rdquo;, &ldquo;<code>open-access-2.html</code>&rdquo;, and &ldquo;<code>open-access-3.html</code>&rdquo;:</p>
										<pre><code># password protect everything except specified files
&lt;IfModule mod_auth.c&gt;
 AuthName "Username and password required"
 AuthUserFile /home/path/.htpasswd
 Require valid-user
 AuthType Basic
 &lt;FilesMatch "(open-access-1.html)|(open-access-2.html)|(open-access-3.html)"&gt;
  Order Deny,Allow
  Deny from all
  Allow from 123.456.789
  Satisfy any
 &lt;/FilesMatch&gt;
&lt;/IfModule&gt;</code></pre>
										<p>Note that we may consolidate the file list as follows:</p>
										<p><code>&lt;FilesMatch "open-access-[1-3]\.html"&gt;</code></p>
										<p>An alternative approach to allowing open access to any file or group of files is to locate them in their own directory with the following directives added to its <acronym title="Hypertext Access">HTAccess</acronym> file:</p>
										<p><code>Allow from all</code><br />
<code>satisfy any</code></p>
										<h3>Wrap it up then</h3>
										<p>As you can see, Apache&rsquo; <code>mod_auth</code> functionality makes it possible to configure just about password-protection setup you may need. From preventing access from specific <acronym title="Internet Protocol">IP</acronym> addresses and domains to allowing access only for specific files and directories, Apache makes it possible to protect your files easily and securely. And we haven&rsquo;t even gotten into the many possibilities available for configuring specific user and group authorizations. I think I&rsquo;ll save that for another article. In the meantime, for more information on Apache&rsquo;s powerful <code>mod_auth</code>, check out the <a href="http://httpd.apache.org/docs/2.2/mod/mod_auth_basic.html" title="Apache Module mod_auth_basic">Official</a> <a href="http://httpd.apache.org/docs/2.0/howto/auth.html" title="Authentication, Authorization and Access Control">Documentation</a>.</p>
										<p><div class="authentic"><span class="hide"><a href="http://perishablepress.com/" title="Perishable Press">Copyright2009PerishablePress</a></span></div></p>
<p>Source: <a href="http://perishablepress.com/press/2009/07/13/htaccess-password-protection-tricks/" title="Read 'HTAccess Password-Protection Tricks' at Perishable Press">Perishable Press</a></p><h6>[ Thank you for subscribing to Perishable Press ]</h6><h3 class="references">Related articles</h3>
				<ul class="refs">
					<li><a href="http://perishablepress.com/press/2007/10/15/ultimate-htaccess-blacklist-2-compressed-version/" title="Ultimate htaccess Blacklist 2 (Compressed Version) (October 15, 2007)">Ultimate htaccess Blacklist 2 (Compressed Version)</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/26/enable-file-or-directory-access-to-your-htaccess-password-protected-site/" title="Stupid htaccess Trick: Enable File or Directory Access to Your Password-Protected Site (November 26, 2007)">Stupid htaccess Trick: Enable File or Directory Access to Your Password-Protected Site</a></li>
					<li><a href="http://perishablepress.com/press/2007/11/28/three-ways-to-allow-hotlinking-in-specific-directories/" title="Three Ways to Allow Hotlinking in Specific Directories (November 28, 2007)">Three Ways to Allow Hotlinking in Specific Directories</a></li>
					<li><a href="http://perishablepress.com/press/2008/01/02/blacklist-candidate-number-2008-01-02/" title="Blacklist Candidate Number 2008-01-02 (January 2, 2008)">Blacklist Candidate Number 2008-01-02</a></li>
					<li><a href="http://perishablepress.com/press/2008/02/10/blacklist-candidate-number-2008-02-10/" title="Blacklist Candidate Number 2008-02-10 (February 10, 2008)">Blacklist Candidate Number 2008-02-10</a></li>
					<li><a href="http://perishablepress.com/press/2008/03/08/blacklist-candidate-number-2008-03-09/" title="Blacklist Candidate Number 2008-03-09 (March 8, 2008)">Blacklist Candidate Number 2008-03-09</a></li>
					<li><a href="http://perishablepress.com/press/2008/04/27/blacklist-candidate-number-2008-04-27/" title="Blacklist Candidate Number 2008-04-27 (April 27, 2008)">Blacklist Candidate Number 2008-04-27</a></li>
				</ul><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=j1gguXK51qA:YdJ5meRLpao:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=j1gguXK51qA:YdJ5meRLpao:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=j1gguXK51qA:YdJ5meRLpao:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/perishablepress?i=j1gguXK51qA:YdJ5meRLpao:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:I9og5sOYxJI"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=I9og5sOYxJI" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/perishablepress?a=j1gguXK51qA:YdJ5meRLpao:bcOpcFrp8Mo"><img src="http://feeds.feedburner.com/~ff/perishablepress?d=bcOpcFrp8Mo" border="0"></img></a>
</div>]]></content:encoded>
			<wfw:commentRss>http://perishablepress.com/press/2009/07/13/htaccess-password-protection-tricks/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
