<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>CSS Newbie</title>
	
	<link>http://www.cssnewbie.com</link>
	<description>Web Development Tutorials, Tips &amp; Techniques</description>
	<pubDate>Sat, 12 Sep 2009 15:53:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/cssnewbie" type="application/rss+xml" /><feedburner:emailServiceId>cssnewbie</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>CSS Newbie + Twitter = CushyCMS Pro Contest!</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/ktd3ppAnQ9M/</link>
		<comments>http://www.cssnewbie.com/css-newbie-twitter-cushycms-pro-contest/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 15:53:28 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Site News]]></category>

		<category><![CDATA[contest]]></category>

		<category><![CDATA[cushycms]]></category>

		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=449</guid>
		<description><![CDATA[I’m getting married today, so I’m going to celebrate by holding a CSS Newbie contest. Up for grabs is a 12-month subscription to CushyCMS Pro! ]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cushycms.com/"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/09/cushycms.png" alt="cushycms" title="cushycms" width="579" height="90" class="alignnone size-full wp-image-452" /></a></p>
<p>By the time you read this, I’ll probably already be wed.</p>
<p>I’m getting married today, so I’m going to celebrate by holding a CSS Newbie contest in my absence! Up for grabs in this contest is <strong>a 12-month subscription to <a href="http://www.cushycms.com/">CushyCMS</a> Pro!</strong> </p>
<p>For those unfamiliar with <a href="http://www.cushycms.com/">CushyCMS, visit their homepage</a> and check out the short video screencast they’ve put together. Basically, CushyCMS is <em>an extremely easy way</em> to give non-web-professionals access to update certain sections of a website, without having to give them access to the source, or build the site in a special templating language. You build the page like regular HTML/PHP/Whatever, add in a couple of classes, and CushyCMS takes care of the rest.<span id="more-449"></span></p>
<p><a href="http://www.cushycms.com/static/pro">The Pro version of CushyCMS,</a> which is what we’re giving away today, has all the benefits of a free account, but allows you to rebrand and customize the interface to your liking, meaning your web clients need never know their site is running CushyCMS. For all they know, they’re running TomCMS. You also gain direct, personal email support, so if you ever run into any problems, help is never more than an email away.</p>
<p>A pro account normally runs $28/month, so this prize has a whopping $336 total value!</p>
<h3>How To Win</h3>
<p>The rules of this contest are pretty simple:</p>
<ol>
<li><a href="http://twitter.com/robbyg">Follow me on Twitter.</a></li>
<li>Tweet a link to your favorite CSS Newbie article (shortened URLs are fine), include at least the title of the article (and a description if you’d like), and give it a hash tag of #cssnewbie</li>
<li>Profit.</li>
</ol>
<p>The contest ends at 6:30pm CDT on September 26, 2009 (two weeks from my marriage).</p>
<p>If you don’t have just one favorite (most useful, whatever) CSS Newbie article, feel free to tweet several times! Each unique tweet counts as an entry into the contest, so multiple entries definitely increase your chances of winning. And if you&#8217;re new to CSS Newbie, a look through the <a href="http://www.cssnewbie.com/toc/">Table of Contents</a> would be a good way to find quality stuff. Or heck, a link to this post would even work! An example of a perfectly legit tweet might look like this:</p>
<pre>A Super Simple Navigation Bar: http://bit.ly/bUDF9 #cssnewbie</pre>
<p>You can @reply it to me if you’d like, but it’s not necessary. At the end of the two week period, I will round up all the tweets containing both the hash tag #cssnewbie and a link to the site, and have a random number generator pick the winner.</p>
<p>Good luck to one and all, and I’ll see you on the other side!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ktd3ppAnQ9M:Y_Mk2YBfdbs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ktd3ppAnQ9M:Y_Mk2YBfdbs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ktd3ppAnQ9M:Y_Mk2YBfdbs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ktd3ppAnQ9M:Y_Mk2YBfdbs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ktd3ppAnQ9M:Y_Mk2YBfdbs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ktd3ppAnQ9M:Y_Mk2YBfdbs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ktd3ppAnQ9M:Y_Mk2YBfdbs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ktd3ppAnQ9M:Y_Mk2YBfdbs:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ktd3ppAnQ9M:Y_Mk2YBfdbs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ktd3ppAnQ9M:Y_Mk2YBfdbs:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/ktd3ppAnQ9M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/css-newbie-twitter-cushycms-pro-contest/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/css-newbie-twitter-cushycms-pro-contest/</feedburner:origLink></item>
		<item>
		<title>A Super Simple Horizontal Navigation Bar</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/MsGj0-K2ORM/</link>
		<comments>http://www.cssnewbie.com/super-simple-horizontal-navigation-bar/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 23:45:14 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Basic Techniques]]></category>

		<category><![CDATA[Navigation]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[semantics]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=444</guid>
		<description><![CDATA[In more cases than not, a simple, no-frills horizontal navigation bar is exactly what the doctor ordered. So today's tutorial is all about going back to basics.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cssnewbie.com/example/horizontal-menu/"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/09/navigation-styled.png" alt="Simple Navigation Bar" title="Simple Navigation Bar" width="579" height="75" class="alignnone size-full wp-image-445" /></a></p>
<p>I occurs to me that, while I&#8217;ve written tutorials on <a href="http://www.cssnewbie.com/tab-based-navigation/">tabbed navigation bars,</a> <a href="http://www.cssnewbie.com/easy-css-dropdown-menus/">dropdown navigation bars,</a> and even <a href="http://www.cssnewbie.com/horizontal-dropdown-menus/">horizontal dropdown navigation bars,</a> I&#8217;ve never stopped to explain how to build a basic, no-frills horizontal navigation bar. And in more cases than not, a simple navigation bar is exactly what the doctor ordered.</p>
<p>So today&#8217;s tutorial is all about going back to basics. This is what you need to know to build a simple navigation bar like the one pictured above (and you can <a href="http://www.cssnewbie.com/example/horizontal-menu/">see a working example here</a>).</p>
<h3>The List</h3>
<p>As with most modern navigation bars, ours will be based on the unordered list (&lt;ul&gt;) tag. This makes semantic sense, a navigation bar is really nothing but a list of links leading into your site. The traditional horizontal orientation is simply a convenient means to get all of our most important list items &#8220;above the fold,&#8221; so the user can see them without having to scroll down the page.<span id="more-444"></span></p>
<p>So here is our sample HTML:</p>
<pre class="html">&lt;ul id=&quot;nav&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;About Us&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Our Products&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;FAQs&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot;&gt;Login&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>That&#8217;s really all it takes! You&#8217;ll notice I did use one ID, so we could tell our navigation bar apart from all the other unordered lists on the page. But if this were tucked into a div with its own ID (like a &#8220;banner&#8221; or &#8220;header&#8221; div), the ID probably wouldn&#8217;t be necessary. And yes, I could add even more IDs and classes if I wanted to make this fancier, but we&#8217;re all about simplicity today.</p>
<h3>Making It Horizontal</h3>
<p>By default, our list is vertical. So let&#8217;s make it horizontal:</p>
<pre class="css">#nav {
	width: 100%;
	float: left;
	margin: 0 0 3em 0;
	padding: 0;
	list-style: none; }
#nav li {
	float: left; }</pre>
<p>Here we&#8217;re floating both our list and our list items left. Floating the list items left is what pulls them into a nice horizontal row for us, stacking the items from left to right. However, because of how floats behave, our containing list will collapse to a height of zero unless it is also floated left. </p>
<p>And that wouldn&#8217;t be a major problem, except I&#8217;m planning to give my list a background color later that I want to show up behind my list items, and if my list collapses, that won&#8217;t happen. That&#8217;s also why I&#8217;m giving my list a width of 100%: That way, it&#8217;ll fill up the entire width of the page (or of its container, if it&#8217;s in a container with a width set).</p>
<p>I&#8217;m also removing most of the margins and padding to make the list behave itself (I&#8217;m leaving some margin on the bottom, simply for aesthetic purposes), and setting the list-style to &#8220;none,&#8221; which removes the bullets from my list.</p>
<p>At this point, our navigation bar looks something like this:</p>
<p><img src="http://www.cssnewbie.com/wp-content/uploads/2009/09/list-no-style.jpg" alt="Unstyled Horizontal Navigation Bar" title="Unstyled Horizontal Navigation Bar" width="579" height="25" class="alignnone size-full wp-image-446" /></p>
<p>Certainly nothing stylish (and probably difficult to use, to boot), but believe it or not, most of our heavy lifting is now done! From this basic framework, you could construct any number of unique navigation bars. But let&#8217;s style ours a bit.</p>
<p>First, we&#8217;ll give our navigation bar a background and some borders by updating our #nav CSS to this:</p>
<pre class="css">#nav {
	width: 100%;
	float: left;
	margin: 0 0 3em 0;
	padding: 0;
	list-style: none;
	background-color: #f2f2f2;
	border-bottom: 1px solid #ccc;
	border-top: 1px solid #ccc; }</pre>
<p>And let&#8217;s give our anchor tags a bit of breathing room and style, too:</p>
<pre class="css">#nav li a {
		display: block;
		padding: 8px 15px;
		text-decoration: none;
		font-weight: bold;
		color: #069;
		border-right: 1px solid #ccc; }</pre>
<p>Here, I&#8217;m giving the anchors a display of &#8220;block&#8221; to make sure they fill up the entire list item and make the whole area clickable. Then I&#8217;m adding some padding to space them out a bit. I&#8217;m also removing the underline, making the font bold, setting our color to a nice blue, and adding a border to the right-hand side of the item, which matches the border we added to the top and bottom of our unordered list.</p>
<p>And finally, let&#8217;s give the navigation items a different color when our users mouse over:</p>
<pre class="css">#nav li a:hover {
		color: #c00;
		background-color: #fff; }</pre>
<p>And just like that, we have a perfectly functional, useable, and useful navigation bar. <a href="http://www.cssnewbie.com/example/horizontal-menu/">You can see it in action here.</a> And here&#8217;s all the CSS in one location:</p>
<pre class="css">#nav {
	width: 100%;
	float: left;
	margin: 0 0 3em 0;
	padding: 0;
	list-style: none;
	background-color: #f2f2f2;
	border-bottom: 1px solid #ccc;
	border-top: 1px solid #ccc; }
#nav li {
	float: left; }
#nav li a {
	display: block;
	padding: 8px 15px;
	text-decoration: none;
	font-weight: bold;
	color: #069;
	border-right: 1px solid #ccc; }
#nav li a:hover {
	color: #c00;
	background-color: #fff; }</pre>
<p>Like I said, this is a useful framework from which to work. 90% of the navigation bars I build start out almost exactly like this. It&#8217;s just a matter of styling them in different ways to get the look you&#8217;re going for.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=MsGj0-K2ORM:1OydXhAeaLU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=MsGj0-K2ORM:1OydXhAeaLU:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=MsGj0-K2ORM:1OydXhAeaLU:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=MsGj0-K2ORM:1OydXhAeaLU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=MsGj0-K2ORM:1OydXhAeaLU:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=MsGj0-K2ORM:1OydXhAeaLU:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=MsGj0-K2ORM:1OydXhAeaLU:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=MsGj0-K2ORM:1OydXhAeaLU:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=MsGj0-K2ORM:1OydXhAeaLU:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=MsGj0-K2ORM:1OydXhAeaLU:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/MsGj0-K2ORM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/super-simple-horizontal-navigation-bar/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/super-simple-horizontal-navigation-bar/</feedburner:origLink></item>
		<item>
		<title>The Importance of Complementary Skills</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/IEOO-Sru9ak/</link>
		<comments>http://www.cssnewbie.com/the-importance-of-complementary-skills/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 20:05:10 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Resources]]></category>

		<category><![CDATA[Review]]></category>

		<category><![CDATA[classes]]></category>

		<category><![CDATA[marketing]]></category>

		<category><![CDATA[teaching]]></category>

		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=438</guid>
		<description><![CDATA[If you've been a reader of CSS Newbie long, you'll have noticed that not all of my articles are about CSS. This is because without complementary skills, CSS can't reach it's potential.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/lencioni/2223801603/"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/08/orange-pear-apple.jpg" alt="Orange, Pear, Apple by Joe Lencioni. Used under a Creative Commons license." title="Orange, Pear, Apple by Joe Lencioni. Used under a Creative Commons license." width="579" height="330" class="alignnone size-full wp-image-439" /></a></p>
<p>If you&#8217;ve been a reader of CSS Newbie for any length of time, I&#8217;m sure you&#8217;ve noticed that not all of my articles are directly related to CSS. I also talk about HTML, JavaScript, content management systems, ecommerce solutions, and other related skill sets and areas of expertise.</p>
<p>This is for many reasons (for starters, I&#8217;d get bored otherwise!), but the main overarching rationale is that these areas of expertise are all complementary. Without HTML, CSS is useless. Without JavaScript, CSS can&#8217;t realize its full potential. </p>
<p>This means these skills are just as important as the CSS my site&#8217;s name suggests you&#8217;ll learn. <span id="more-438"></span></p>
<p>However, there&#8217;s only so much I can teach. I&#8217;m not an expert in everything related to web development, nor will I ever be. And while I consider myself pretty decent at writing these tutorials (which means my English degree wasn&#8217;t a <em>total</em> waste!), I consider myself to be a complete newbie when it comes to the art of &#8220;selling&#8221; my knowledge and authority. If there is such a thing as a natural marketer, I am not he.</p>
<p>Earlier this year, I came across Brian Clark&#8217;s (of Copyblogger fame) <a href="http://teachingsells.com?ref=65988e3d">online course called Teaching Sells.</a> I was immediately intrigued. Here was a guy with a complementary skill set who was willing to teach me what he knew. Brian&#8217;s expertise is not in building web sites, but in writing and teaching: the other half of what I do.</p>
<p>So I signed up for the Teaching Sells mailing list and <a href="http://teachingsells.com?ref=65988e3d">downloaded their free report</a> with the great title, &#8220;Forget Everything You Know About Making Money Online&#8230; And Start Making Some.&#8221; And that report was pretty motivating for me. So when the class opened up in February, I signed up right away.</p>
<p>I started out very excited and motivated.  The course is full of detailed information, and comes with a lot of worksheets and planning guides you can download and fill out to map what you&#8217;re learning to your own personal projects (I have a manila folder full of those worksheets). But then&#8230; well, I&#8217;ll admit it: I didn&#8217;t make it all the way through the course! </p>
<p>I got busy with work, with freelancing, with planning my wedding (only <em>17 days</em> to go now!). But here&#8217;s one benefit of the program that I don&#8217;t think Brian and his crew tout loudly enough: Once you&#8217;re a member of <a href="http://teachingsells.com?ref=65988e3d">Teaching Sells</a>, you&#8217;re <strong>a member for life.</strong></p>
<p>What does that mean? That means I can go back whenever I want, and I&#8217;ll still have access to the dozens of learning modules, the forums, the downloads, the interviews&#8230; and anything new they decide to add to the mix down the road. So my new and revised goal is to take up the class again this fall, start back up with a whole new group of motivated, excited students, and see if I can make it all the way through this time.</p>
<p>So if you&#8217;ve got a few minutes, take my advice: <a href="http://teachingsells.com?ref=65988e3d">head over to Teaching Sells</a> and watch the new video they have up that explains what it is they do better than I ever could (they&#8217;re the marketers, after all). </p>
<p>And if you think their pitch sounds plausible, <a href="http://teachingsells.com?ref=65988e3d">sign up for their email list.</a> You&#8217;ll get the free report, some case studies in your inbox to get you started, and once they open the doors to their class, you&#8217;ll be the first to know. </p>
<p>And if all goes well, I&#8217;ll see you in the forums.</p>
<p>(<strong>Note:</strong> Yes, the links above are affiliate links &mdash; past members of the program are given the option to be affiliates for future offerings. This means if you click one of those links and sign up, you&#8217;re helping CSS Newbie. However, even if there weren&#8217;t an affiliate program, I&#8217;d still recommend this course to anyone and everyone looking to learn the art of teaching online! So check it out.)</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=IEOO-Sru9ak:4w0BMg91ME0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=IEOO-Sru9ak:4w0BMg91ME0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=IEOO-Sru9ak:4w0BMg91ME0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=IEOO-Sru9ak:4w0BMg91ME0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=IEOO-Sru9ak:4w0BMg91ME0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=IEOO-Sru9ak:4w0BMg91ME0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=IEOO-Sru9ak:4w0BMg91ME0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=IEOO-Sru9ak:4w0BMg91ME0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=IEOO-Sru9ak:4w0BMg91ME0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=IEOO-Sru9ak:4w0BMg91ME0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/IEOO-Sru9ak" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/the-importance-of-complementary-skills/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/the-importance-of-complementary-skills/</feedburner:origLink></item>
		<item>
		<title>Running jQuery with Other Frameworks Via noConflict</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/CNRL-m8SoNk/</link>
		<comments>http://www.cssnewbie.com/runing-jquery-with-other-frameworks-via-noconflict/#comments</comments>
		<pubDate>Tue, 07 Jul 2009 15:40:18 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Basic Techniques]]></category>

		<category><![CDATA[Bugs and Fixes]]></category>

		<category><![CDATA[Frameworks and Libraries]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[dojo]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[js]]></category>

		<category><![CDATA[mootools]]></category>

		<category><![CDATA[no conflict]]></category>

		<category><![CDATA[noconflict]]></category>

		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=430</guid>
		<description><![CDATA[While there's nothing to stop you from using multiple frameworks simultaneously, compatability problems can pop up &#8212; particularly between jQuery and Prototype. Luckily, there's a simple solution called noConflict mode.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/romainguy/230416692/"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/07/chess_romainguy.jpg" alt="Photo &quot;Chess&quot; by Romainguy. Used under a Creative Commons license." title="Photo &quot;Chess&quot; by Romainguy. Used under a Creative Commons license." width="579" height="250" class="size-full wp-image-432" /></a></p>
<p>While <a href="http://jquery.com/">jQuery</a> is certainly a popular JavaScript framework, it&#8217;s by no means the only game in town. Other frameworks such as <a href="http://www.prototypejs.org/">Prototype</a>, <a href="http://mootools.net/">MooTools</a>, <a href="http://www.dojotoolkit.org/">Dojo</a> and many others all have their own strengths, weaknesses, and devoted groupies.</p>
<p>Generally speaking, these frameworks all play well together &mdash; you can mix and match framework functionality to your heart&#8217;s content, as long as you don&#8217;t mind the additional overhead of loading several libraries simultaneously. So you have a calendar widget in jQuery that you love, but you&#8217;re already using Prototype to animate your navigation bar? Don&#8217;t be shy&#8230; use both!</p>
<p>Of course, every once in a while you can run in to problems when combining JS frameworks &mdash; particularly (in my experience) when combining jQuery and Prototype.  Luckily, jQuery was kind enough to provide us with a workaround.<span id="more-430"></span></p>
<h3>The Problem: Sharing Syntax</h3>
<p>The most common compatibility problem stems from both jQuery and Prototype using the same shortcut syntax: namely, the <em>$().doSomething</em> syntax. Here&#8217;s a sample line of code in jQuery:</p>
<pre class="js">$('#myelement').addClass('active');</pre>
<p>And the same functionality in Prototype:</p>
<pre class="js">$('myelement').addClassName('active');</pre>
<p>Note the basic similarity? Both frameworks claim the dollar sign notation for themselves, which can wreak havoc on snippets of code dropped willy-nilly into a website. If your jQuery code is grabbed up by Prototype, things will stop working fast. And similarly, if your Prototype code is snagged by jQuery, not even the awesome power of jQuery will be enough to overcome the code confusion.</p>
<h3>The Solution: noConflict Mode</h3>
<p>But not to worry! jQuery has provided us with a workaround called &#8220;noConflict mode.&#8221;</p>
<p>By default, there are two equally correct ways to call a jQuery function &mdash; the dollar sign notation, and &#8220;jQuery&#8221; notation:</p>
<pre class="js">$('#myelement').show();
jQuery('#myelement').show();</pre>
<p>Both of the lines above do exactly the same thing. However, most people use and prefer the dollar sign notation. Why? Probably because it&#8217;s shorter, and if web developers didn&#8217;t care about brevity in their code, they probably wouldn&#8217;t have used a framework in the first place.</p>
<p>Of course, just using the longer jQuery notation isn&#8217;t enough. If jQuery has already claimed the dollar sign for itself, any Prototype functionality relying on that notation will still be grabbed by jQuery. </p>
<p>This is where the noConflict function comes in handy. Simply run the following line after both Prototype and jQuery have been loaded:</p>
<pre class="js">jQuery.noConflict();</pre>
<p>This will cause jQuery to give up the dollar-sign notation, allowing the other library to take it over. And you can still use your jQuery snippet, provided you change all instances of $() to jQuery().</p>
<h3>Keeping it Short</h3>
<p>The noConflict mode does have one other bit of functionality that I&#8217;ve found useful in some of my projects: you can select a different variable to use instead of the standard &#8220;jQuery&#8221;. The usage looks like this:</p>
<pre class="js">var $j = jQuery.noConflict();</pre>
<p>Now in addition to using the default jQuery() notation, I can also use the shorter $j() notation. This allows me to avoid running into problems with other frameworks, while still enjoying almost the same conciseness in my code.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=CNRL-m8SoNk:1PmzD1-H1rI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=CNRL-m8SoNk:1PmzD1-H1rI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=CNRL-m8SoNk:1PmzD1-H1rI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=CNRL-m8SoNk:1PmzD1-H1rI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=CNRL-m8SoNk:1PmzD1-H1rI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=CNRL-m8SoNk:1PmzD1-H1rI:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=CNRL-m8SoNk:1PmzD1-H1rI:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=CNRL-m8SoNk:1PmzD1-H1rI:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=CNRL-m8SoNk:1PmzD1-H1rI:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=CNRL-m8SoNk:1PmzD1-H1rI:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/CNRL-m8SoNk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/runing-jquery-with-other-frameworks-via-noconflict/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/runing-jquery-with-other-frameworks-via-noconflict/</feedburner:origLink></item>
		<item>
		<title>Using JavaScript to Style Active Navigation Elements</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/WFmpM51NipQ/</link>
		<comments>http://www.cssnewbie.com/using-javascript-to-style-active-navigation-elements/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 00:53:43 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Advanced Techniques]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Navigation]]></category>

		<category><![CDATA[functions]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=424</guid>
		<description><![CDATA[I'm all about efficiency when I'm writing web code, and navigation is often one of those areas where I try to improve my efficiency. Here are some ways to automatically style your "active" navigation elements using some streamlined JavaScript and/or jQuery.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.cssnewbie.com/wp-content/uploads/2009/04/active-nav.png" alt="active navigation element" title="active navigation element" width="579" height="125" class="alignnone size-full wp-image-426" /></p>
<p>I&#8217;m all about efficiency when I&#8217;m writing web code. Any time I find myself writing the same functionality more than once or twice, I try to consider whether my repeated code could be wrapped into a function of some sort.</p>
<p>Navigation is often one of those areas where I try to improve my efficiency. I like my navigation elements to pull double duty. I want them to:</p>
<ol>
<li>Show the user <em>where they can go,</em> and</li>
<li>Show the user <em>where they currently are.</em></li>
</ol>
<p>In other words, I want some sort of visual indication in my navigation that shows my user which section of my site they&#8217;re in. You can see this on the CSS Newbie site: if you click on <a href="http://www.cssnewbie.com/toc/">the TOC (Table of Contents) link</a> in the bar at the top of the page, you&#8217;ll see that link gets special styling when the table of content loads.</p>
<p>Now, I could manually set this on every page using a CSS class. But that&#8217;s inefficient &mdash; depending on the size of my site, I could end up writing dozens or hundreds of lines of one-off code. And why go to all that work, when you could just wrap it all up into a nice JavaScript function?<span id="more-424"></span></p>
<p>First, I&#8217;ll explain the logic behind my functions &mdash; because they won&#8217;t work equally well for every site. Then I&#8217;ll walk you through a few examples of the code that makes it all happen.</p>
<h3>The Logic</h3</p>
<p>All of my functions assume a very clean, straightforward directory structure. For example, if you have an About section, a Blog section, and a Contact section on your site, a logical directory structure might be: </p>
<pre>/
/about/
/blog/
/contact/
</pre>
<p>And if you had several blog entries inside your blog directory, your structure might grow like this:</p>
<pre>/
/about/
/blog/
/blog/post-one/
/blog/post-two/
/blog/post-three/
/contact/
</pre>
<p>And therefore, a function could logically assume that anything inside the blog directory should be considered a part of the blog section of your site, and mark the blog link as active for those pages. This makes our job a lot easier. And luckily, most CMS platforms make this sort of directory structure pretty easy to create.</p>
<p>The functions also assume that you have either a fairly shallow directory structure, or that you&#8217;re not linking to too many similarly nested directories. What I mean by this is, if you have this sort of a structure:</p>
<pre>/
/contact/
/contact/me/
/contact/me/here/
</pre>
<p>And you wanted to link to both /contact/ and /contact/me/here/ in your navigation bar, you might run into problems distinguishing between the two. There are ways to increase precision, but they come at the cost of flexibility. </p>
<p>But enough of that. Let&#8217;s get to the good stuff!</p>
<h3>A JavaScript Solution</h3>
<p>I&#8217;ve written about this method before, when I previously talked about <a href="http://www.cssnewbie.com/intelligent-navigation/">building intelligent navigation bars.</a> This technique is nice because it doesn&#8217;t rely on any JS frameworks, so you can add it to older sites without needing jQuery or the like. The basic function looks like this:</p>
<pre class="js">function setActive() {
  aObj = document.getElementById('nav').getElementsByTagName('a');
  for(i=0;i&lt;aObj.length;i++) {
    if(document.location.href.indexOf(aObj[i].href)&gt;=0) {
      aObj[i].className='active';
    }
  }
}</pre>
<p>This function looks for an element with an id of &#8220;nav&#8221; (presumably your navigation bar), then looks at each of the anchor tags inside it. It then compares the anchor tag&#8217;s href tag with the page&#8217;s URL. If the href tag is contained within the URL anywhere, it gives that link a class of &#8220;active,&#8221; which I can then style specially in my CSS.</p>
<p>As an example of what I mean by all that, if I had an anchor tag in my navigation bar that linked to &#8220;/blog/&#8221; and the page I was on was &#8220;/blog/this-is-a-post.html&#8221;, my blog link would be styled as active, because &#8220;/blog/&#8221; is contained within &#8220;/blog/this-is-a-post.html&#8221;.</p>
<p>As a final note, you wouldn&#8217;t want to call this function until the page was finished loading: if you call it too soon, your links won&#8217;t exist yet! So you can either call it at the very end of your document, or dynamically call it when your page is done loading, with something like this:</p>
<pre class="js">window.onload = setActive;</pre>
<h3>A jQuery Solution</h3>
<p>If you are already loading a framework like jQuery (like I do on almost every site I work on these days), this sort of functionality could be written even more succinctly. And like I said earlier, I&#8217;m a sucker for efficiency. Here&#8217;s a jQuery solution that does essentially the same thing in a much smaller space:</p>
<pre class="js">$(document).ready(function() {
	$('#nav a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
});</pre>
<p>This function is making use of both native JavaScript and jQuery tricks to reach a whole new level of brevity. First, the whole thing is wrapped in a &#8220;document ready&#8221; function, which means it won&#8217;t fire until the page is loaded and our links are in place. Next, we&#8217;re looking for anchor tags inside our &#8220;nav&#8221; ID. And really, we&#8217;re looking for a very specific anchor tag: one whose href <strong>starts with</strong> (^=) a slash, followed by a part of our <strong>page&#8217;s location</strong> (location.pathname). Specifically, we&#8217;re looking for the first directory in our page&#8217;s URL.</p>
<p>We&#8217;re doing this by making use of the JavaScript split() method, which lets us take any string (for example, &#8220;/blog/this-is-a-post.html&#8221;) and break it into an array based on a substring (in our case, the forward slash). If you&#8217;re familiar with PHP, it&#8217;s similar to the explode() function. In our example, we&#8217;d end up with a three-part array that looked like this: </p>
<pre>["","blog","this-is-a-post.html"]</pre>
<p>Which means that if we look at the second value of our array (arrays start counting at zero, so [1] is the second value), that should give our first-level directory (&#8221;blog&#8221;, in our example). This lets us match any subsequent child directories with our parent in the navigation bar.</p>
<h3>Tweaking for Home Links</h3>
<p>Our jQuery function works great in most scenarios, but it fails if you have a &#8220;home&#8221; link where you&#8217;re just pointing to the root directory, like this:</p>
<pre class="html">&lt;a href=&quot;/&quot;&gt;Home&lt;/a&gt;</pre>
<p>And because I tend to have a link like that, I needed a workaround. Here&#8217;s a way to get around that with just a little more code to account for our special case:</p>
<pre class="js">$(document).ready(function() {
	if(location.pathname != "/") {
		$('#nav a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active');
	} else $('#nav a:eq(0)').addClass('active');
});</pre>
<p>Here, we&#8217;re checking to see if we&#8217;re in the root directory. If so, we&#8217;re skipping the loop through our anchor tags and just making a specific anchor tag active. In this case, I&#8217;m giving the active class to the first anchor in our list (which is the most common location for a home link).</p>
<p>And that&#8217;s that. If you know of even more efficient or fool-proof ways to accomplish this task, I&#8217;d love to hear about them in the comments section. Or if you&#8217;re skilled in a framework other than jQuery, feel free to share the equivalent code!</p>
<p>Note: I apologize for the long gap between articles. I had some problems while rebuilding my PC (DOA motherboard) and was without my computer for several weeks.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=WFmpM51NipQ:LKWSYBv7T30:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=WFmpM51NipQ:LKWSYBv7T30:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=WFmpM51NipQ:LKWSYBv7T30:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=WFmpM51NipQ:LKWSYBv7T30:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=WFmpM51NipQ:LKWSYBv7T30:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=WFmpM51NipQ:LKWSYBv7T30:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=WFmpM51NipQ:LKWSYBv7T30:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=WFmpM51NipQ:LKWSYBv7T30:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=WFmpM51NipQ:LKWSYBv7T30:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=WFmpM51NipQ:LKWSYBv7T30:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/WFmpM51NipQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/using-javascript-to-style-active-navigation-elements/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/using-javascript-to-style-active-navigation-elements/</feedburner:origLink></item>
		<item>
		<title>Reader Response: A Simple, Streamlined E-Commerce Solution</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/ZqlyRG_DpEY/</link>
		<comments>http://www.cssnewbie.com/a-simple-streamlined-e-commerce-solution/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 16:01:48 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Ecommerce]]></category>

		<category><![CDATA[Polls]]></category>

		<category><![CDATA[Resources]]></category>

		<category><![CDATA[foxycart]]></category>

		<category><![CDATA[payflow]]></category>

		<category><![CDATA[paypal]]></category>

		<category><![CDATA[poll]]></category>

		<category><![CDATA[shopping cart]]></category>

		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=418</guid>
		<description><![CDATA[Today I come to you with my arms wide open &#8212; and my shoulders caught somewhere between a slump and a shrug. I've been tearing my hair out over the last couple of months looking for the perfect ecommerce solution. I've come up short.]]></description>
			<content:encoded><![CDATA[<p>Today, dear readers, I come to you with my arms wide open &mdash; and my shoulders caught somewhere between a slump and a shrug. I&#8217;ve been tearing my hair out over the last couple of months looking for the perfect ecommerce solution for my specific needs and wants. I&#8217;ve come up short.</p>
<p>But it occurs to me that I have a lot of smart, savvy readers here on CSS Newbie &mdash; and maybe, just maybe, you&#8217;ll be able to help me find the perfect shopping cart. Below, I&#8217;ll explain specifically what I&#8217;m looking for (and a bit about what I&#8217;m <em>not</em> looking for, too). If you know of a cart that meets my needs &mdash; or even just some of them &mdash; <strong>please</strong> do not hesitate to let me know! I&#8217;m hoping that the comments on this article will prove as plentiful as Starbucks on the open prairie. And twice as useful.<span id="more-418"></span></p>
<h3>I Want a Simple, User-Friendly Cart that Stays Out of My Way.</h3>
<p>That about sums it up, really. But for more detail, here&#8217;s what I want/need in a cart:</p>
<ul>
<li><strong>A self-hosted solution.</strong> If it weren&#8217;t for this requirement, I think<a href="http://www.foxycart.com/"> Foxycart would be my #1 contender.</a> Consider that a hint &mdash; if you know of something Foxycart-eque, but is self-hosted instead, <em>please</em> let me know!</li>
<li><strong>Supports everything <a href="https://www.paypal.com/">PayPal</a> has to offer.</strong> Specifically, I want something that can support <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_wp-pro-overview-outside&#038;nav=2.0.1">Website Payments Pro</a> and the <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_payflow-pro-overview-outside">Payflow Pro</a> gateway. This way I can handle payments on my site, but still take advantage of PayPal&#8217;s expertise, PCI compliance, and competitive pricing.</li>
<li><strong>Flexible, <em>straightforward</em> templating.</strong> I am a front-end developer. Any cart solution that tries to stand between me and my code or that makes templating a holy hell isn&#8217;t a good solution. I want simple, straightforward flexibility. For example, I&#8217;ve been working with <a href="http://www.magentocommerce.com/">Magento</a> a lot recently, and while it has a lot of great features, it&#8217;s a <strong>huge</strong> pain to deviate too far from the standard build. Every small change requires updates in multiple disparate files and hours of time for a five-minute job. My ideal solution would let me build my pages however I wanted, and just drop in the &#8220;cart&#8221; functionality wherever I cared to do so.</li>
<li><strong>Good support of downloadable products.</strong> The stores I&#8217;m building will have both hard and soft goods, so I need the cart to work equally smoothly with both.</li>
<li><strong>Built for <a href="http://en.wikipedia.org/wiki/LAMP_(software_bundle)">LAMP</a> servers.</strong> The ideal solution would run on PHP/MySQL, but I would consider other LAMP-friendly options. Sorry, but ASP/.NET solutions aren&#8217;t a possibility for me.</li>
<li><strong>A single product database.</strong> This solution will be running multiple stores, but several of the stores will share some products. In the interest of avoiding redundant data, I&#8217;d like to have a single product database that all my stores can draw from.</li>
<li><strong>Access to the source.</strong> I don&#8217;t want to have to wait for a team halfway around the world or a community of volunteer developers to get around to building the functionality I need if I think I could tackle the project myself. If I can&#8217;t have access to the source itself, an exceptional plugin system would be a good alternative.</li>
<li><strong>A flexible discounting system.</strong> I want to be able to offer (as a fake example) 20% off orders of $50 or more on certain products. I want to discount items if people buy two or more of the same product. I want sales that run for three weeks, and expire automatically. Or at least some of those things.</li>
</ul>
<p>That&#8217;s the basics of what I need, folks. That isn&#8217;t too much to ask, is it?</p>
<p>To summarize, <strong>I&#8217;m looking for a simple, straightforward shopping cart that makes templating a breeze, runs on PHP/MySQL, supports PayPal gateways, allows virtual goods and discounts, and is something I can install locally and modify.</strong> I do not need a solution that tries to be everything at once &mdash; it doesn&#8217;t have to contain a CMS, a catalog, or an inventory system. It doesn&#8217;t have to provide a newsletter, it needn&#8217;t compare items, and it shouldn&#8217;t try to walk my dog on Thursdays. I don&#8217;t want a jack-of-all-trades: I want a master of one (or two).</p>
<p>I also want to clarify: <strong>this does not have to be a free solution.</strong> If you know of a commercial option that does all this, I would be <em>very</em> excited to hear about it.</p>
<p>So! Let me know what you know in the comments below. Even if you know of a cart that fulfills <em>some</em> of these needs, I would be excited to hear about it &mdash; there&#8217;s always the chance I can customize it to do what I need from there.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZqlyRG_DpEY:rSjOiz3y6Oo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZqlyRG_DpEY:rSjOiz3y6Oo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZqlyRG_DpEY:rSjOiz3y6Oo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZqlyRG_DpEY:rSjOiz3y6Oo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZqlyRG_DpEY:rSjOiz3y6Oo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZqlyRG_DpEY:rSjOiz3y6Oo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZqlyRG_DpEY:rSjOiz3y6Oo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZqlyRG_DpEY:rSjOiz3y6Oo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZqlyRG_DpEY:rSjOiz3y6Oo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZqlyRG_DpEY:rSjOiz3y6Oo:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/ZqlyRG_DpEY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/a-simple-streamlined-e-commerce-solution/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/a-simple-streamlined-e-commerce-solution/</feedburner:origLink></item>
		<item>
		<title>A Simple jQuery Stylesheet Switcher</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/ZWTG4BKw32Y/</link>
		<comments>http://www.cssnewbie.com/simple-jquery-stylesheet-switcher/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 01:48:36 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Basic Techniques]]></category>

		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Quick Tip]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[jquery]]></category>

		<category><![CDATA[stylehseet]]></category>

		<category><![CDATA[swap]]></category>

		<category><![CDATA[switch]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=410</guid>
		<description><![CDATA[There are lots of reasons you might want to offer your users more than one CSS file for your website. But whatever the reason, it's amazingly easy to create a function that swaps between multiple stylesheets using a few lines of jQuery.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.cssnewbie.com/example/stylesheet-switcher/"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/04/stylesheeet-switcher.gif" alt="jQuery stylesheeet switcher" title="jQuery stylesheeet switcher" width="579" height="150" class="alignnone size-full wp-image-412" /></a></p>
<p>There are lots of reasons you might want to offer your users more than one CSS file for your website:</p>
<ul>
<li>You want to offer a &#8220;stylish&#8221; low-contrast and an easy-to-read high-contrast version of your site.</li>
<li>You have many low-vision readers and want to give them easy access to a customized stylesheet with a larger typeface.</li>
<li>Your site is schizophrenic and you want to be able to change the look quickly.</li>
</ul>
<p>Whatever the reason, it&#8217;s amazingly easy to create a function that swaps between multiple stylesheets using jQuery.</p>
<p>The first step of course is to build several different CSS files, which we&#8217;ll then swap between. Once that is done, we can dive into the XHTML and jQuery that makes the magic happen.<span id="more-410"></span></p>
<h3>The XHTML</h3>
<p>First, we need to create a set of links that will allow the user to swap between CSS files. You can make this as simple or as fancy as you&#8217;d like. For the sake of brevity, my links are simple:</p>
<pre class="html">&lt;ul id=&quot;nav&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot; rel=&quot;/path/to/style1.css&quot;&gt;Default CSS&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot; rel=&quot;/path/to/style2.css&quot;&gt;Larger Text&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#&quot; rel=&quot;/path/to/style3.css&quot;&gt;Something Different&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre>
<p>Here I have three links, each with a &#8220;rel&#8221; attribute indicating which CSS file the link will load. Technically, I could have just as easily put this information in the &#8220;href&#8221; attribute, but I didn&#8217;t want to for one specific reason: if the user has JavaScript disabled and the CSS file is listed in the href, then clicking the link will send the user to the CSS file directly (not loading it like we intended). But our way, if JS is disabled, the user gets nothing at all: which is certainly preferable to the less savory alternative.</p>
<h3>The jQuery</h3>
<p>Like I promised, the jQuery is really simple:</p>
<pre class="js">$(document).ready(function() {
	$("#nav li a").click(function() {
		$("link").attr("href",$(this).attr('rel'));
		return false;
	});
});</pre>
<p>This function waits until the document is loaded (generally an important step when interacting with the DOM), then attaches a click function to each of our nav anchors. The function basically says, &#8220;when someone clicks on this link, replace the link (stylesheet) tag&#8217;s href attribute with the contents of this link&#8217;s rel attribute.&#8221;  The &#8220;return false&#8221; at the end just stops the browser from trying to follow the link.</p>
<p>Of course, you might have to get more detailed if you have more than one link tag, for example, but that&#8217;s easily done by giving the link tag a class (&#8221;changeme,&#8221; for argument&#8217;s sake), and writing something like this:</p>
<pre class="js">$("link.changeme").attr("href",$(this).attr('rel'));</pre>
<p>And while this stylesheet switcher is already complete, we might want to give it some memory: after all, your users might get annoyed if they have to switch their styles back to their preferences every time they visit your site. For that, we&#8217;ll need to set a cookie. And to make that easier, I&#8217;ll use <a href="http://plugins.jquery.com/project/Cookie">the jQuery cookie plugin</a> (which <a href="http://www.cssnewbie.com/jquery-popout-ad-part-3/">I&#8217;ve talked about previously when building a popout ad</a>).</p>
<p>With the plugin loaded, we can modify our jQuery thusly:</p>
<pre class="js">$(document).ready(function() {
	if($.cookie("css")) {
		$("link").attr("href",$.cookie("css"));
	}
	$("#nav li a").click(function() {
		$("link").attr("href",$(this).attr('rel'));
		$.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});
		return false;
	});
});</pre>
<p>Now we have two statements. The first one checks as soon as the page is done loading to see if a cookie called &#8220;css&#8221; has been set. If so, it sets the stylesheet to be the one indicated in that cookie. Otherwise, it does nothing.</p>
<p>Our click function is much the same, except after we set the stylesheet, we also set a cookie. This cookie doesn&#8217;t expire for an entire year (and each time the user changes their stylesheet preferences, it would reset this timer), giving them a good 365 of CSS bliss.</p>
<h3>Fine Tuning</h3>
<p>There is one minor annoyance with this stylesheet switcher: there&#8217;s generally a flash of the &#8220;default&#8221; CSS when the user loads the page. That&#8217;s because the script waits until the document is &#8220;ready&#8221; before switching the link&#8217;s href. There is a way around this: moving the first &#8220;if&#8221; statement outside of the document ready function, like so:</p>
<pre class="js">if($.cookie("css")) {
	$("link").attr("href",$.cookie("css"));
}
$(document).ready(function() {
	$("#nav li a").click(function() {
		$("link").attr("href",$(this).attr('rel'));
		$.cookie("css",$(this).attr('rel'), {expires: 365, path: '/'});
		return false;
	});
});</pre>
<p>Generally speaking, you don&#8217;t want to run any jQuery until your document is ready. However, so long as your jQuery comes <em>after your link tag</em> in your document structure, like shown below, this shouldn&#8217;t be a major concern:</p>
<pre class="html">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style1.css&quot; /&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;jquery.cookie.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;... your jQuery goes here...&lt;/script&gt;</pre>
<p>This means your jQuery will run before the document is done loading, and thus your link tag&#8217;s href will be swapped before your CSS has been applied. As I said before, it&#8217;s generally a bad idea to manipulate the DOM before document ready, but because we know the exact tag we want to manipulate and can place our jQuery below it in the DOM, we should be safe in this one specific instance.</p>
<p><a href="http://www.cssnewbie.com/example/stylesheet-switcher/">Here&#8217;s an example if you would like to see this technique in action.</a></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZWTG4BKw32Y:I1a58WSN6qo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZWTG4BKw32Y:I1a58WSN6qo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZWTG4BKw32Y:I1a58WSN6qo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZWTG4BKw32Y:I1a58WSN6qo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZWTG4BKw32Y:I1a58WSN6qo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZWTG4BKw32Y:I1a58WSN6qo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZWTG4BKw32Y:I1a58WSN6qo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZWTG4BKw32Y:I1a58WSN6qo:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ZWTG4BKw32Y:I1a58WSN6qo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ZWTG4BKw32Y:I1a58WSN6qo:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/ZWTG4BKw32Y" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/simple-jquery-stylesheet-switcher/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/simple-jquery-stylesheet-switcher/</feedburner:origLink></item>
		<item>
		<title>15 Surefire Ways to Break Your CSS</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/ib8CLW9iaO8/</link>
		<comments>http://www.cssnewbie.com/15-surefire-ways-to-break-your-css/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 19:28:23 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Basic Techniques]]></category>

		<category><![CDATA[Bugs and Fixes]]></category>

		<category><![CDATA[IDs and Classes]]></category>

		<category><![CDATA[Organization]]></category>

		<category><![CDATA[bugs]]></category>

		<category><![CDATA[errors]]></category>

		<category><![CDATA[properties]]></category>

		<category><![CDATA[rules of css]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=403</guid>
		<description><![CDATA[When your CSS doesn't behave the way it should, web design can be downright tedious. But some of the the biggest CSS blunders stem from the simplest of errors. Knowing what some of those errors are and remembering to look for them can save you hours of wasted labor.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/ultimateslug/109566859/"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/03/broken-monitor.jpg" alt="&#039;Fixed&#039; by Don Fulano. Used under a Creative Commons license." title="&#039;Fixed&#039; by Don Fulano. Used under a Creative Commons license." width="579" height="250" class="alignnone size-full wp-image-404" /></a></p>
<p>The life of a CSS developer isn&#8217;t all about attending glamorous champagne parties, jet-setting around the world and hanging out with supermodels. In fact, when your CSS doesn&#8217;t behave the way it should, the job can be downright tedious. I&#8217;ve spent untold hours of my life debugging my code &mdash; and I&#8217;m guessing I&#8217;m not alone here.</p>
<p>But as silly as it may seem, some of the biggest CSS blunders stem from the simplest of errors. Knowing what some of those errors are and remembering to look for them can save you hours of wasted labor. Here are fifteen ways I&#8217;ve found to break my CSS for sure &mdash; and fifteen things I always look for whenever I have a problem in my code.<span id="more-403"></span></p>
<h3>Missing a Semicolon</h3>
<p>CSS rules are comprised of property-value pairs (declarations) followed by a semicolon. Accordng to the CSS specification, the last declaration doesn&#8217;t need a semicolon &mdash; because the closing brace effectively ends the declaration just as well. That means something like this is perfectly acceptable: </p>
<pre class="css">body {
	background-color: #444;
	color: #eee }</pre>
<p>The only problem is, as soon as you decide to add another declaration to your previous rule, you&#8217;ve now made it all too easy to forget to add the semicolon to your once-last rule:</p>
<pre class="css">body {
	background-color: #444;
	color: #eee
font-family: Helvetica, Arial, sans-serif }</pre>
<p>The result? Your font-family rule never gets applied, because the parser reads &#8220;font-family&#8221; as part of the color value. Which is why I make a habit of adding the final semicolon in a rule, no matter what.</p>
<h3>Missing a Colon</h3>
<p>I&#8217;ve seen this particular problem crop up frequently while teaching classes on CSS. People get excited when CSS starts to make sense, and their typing speed increases. The downside: this makes errors of omission much more likely. And a missing colon is particularly tough to see, since it sits right in the middle of a declaration. Consider the following two lines:</p>
<pre class="css">body { font-family Helvetica, Arial, sans-serif; }
body { font-family: Helvetica, Arial, sans-serif; }</pre>
<p>It&#8217;s easy to see how the colon could get overlooked in the jumble of braces, hyphens, semicolons and cryptic words. As a rule of thumb, if you only have one declaration not behaving itself, this is a good place to start looking.</p>
<h3>Missing a Brace</h3>
<p>{Braces} around a CSS rule are like the circle of life: regular, natural, and expected. And if you ever miss a brace (generally a closing brace for whatever reason) &#8212; just like if you have a zombified corpse that refuses to die &#8212; you suddenly have all sorts of mayhem on your hands.</p>
<p>When an unsuspecting browser comes across a pair of rules like this:</p>
<pre class="css">body {
	font-family: Helvetica, Arial, sans-serif;
#wrap {
	width: 960px; }</pre>
<p>The browser is going to choke. Two opening braces before a closing brace is right out: everything from your #wrap rule (in this example) on would be ignored. </p>
<p>However, this does make debugging easier. Do you have a whole chunk of CSS being ignored? Which is the first rule that is being neglected? There&#8217;s a good chance you have an uneven number of braces hanging out in the vicinity.</p>
<h3>Misspelled Properties</h3>
<p>I consider the following few errors the bane of dyslexic developers everywhere. Generally speaking, I&#8217;m a good speller. But when I&#8217;m &#8220;in the zone&#8221; and typing as fast as my fingers can carry me, I tend to transpose a few letters here and there. In writing, this isn&#8217;t such a big deal: people can generally figure out what I mean. Computers, sadly, are less discerning. </p>
<pre class="css">div { border-bototm: 5px; }</pre>
<p>Now, I have no idea what a &#8220;bototm&#8221; is, but I do know I write the word at least one time in five when I&#8217;m trying to refer to the lower edge of an element. I&#8217;m lucky in that I have a decent eye for editing and often catch these mistakes as I make them. If you&#8217;re not so fortunate, using a program with code coloring like <a href="http://notepad-plus.sourceforge.net">Notepad++</a> or <a href="http://www.amazon.com/gp/product/B001EUDIZE?ie=UTF8&#038;tag=cssnewbie-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B001EUDIZE">Adobe Dreamweaver (my personal favorite)</a> can make the job a lot easier: if a property isn&#8217;t colored like the other properties, than it&#8217;s probably not much of a property at all.</p>
<h3>Misspelled Values</h3>
<p>Misspellings aren&#8217;t limited to just properties. And sometimes a misspelled value can be even more difficult to notice:</p>
<pre class="css">#wrap { padding: 10px 20pz 25px 20px; }</pre>
<p>Unfortunately for the rule above, I&#8217;m fairly sure only Snoop Dogg and I have ever tried to measure elements in pizzles. Instead of the generous padding you&#8217;d expect this rule to generate, this one misspelled unit renders the entire declaration invalid.</p>
<h3>Misspelled Classes and IDs</h3>
<p>No matter how often I create a div with an ID of &#8220;navigation,&#8221; I still find myself writing rules that look more like this:</p>
<pre class="css">#navigaiton { float: left; } </pre>
<p>This can be a frustrating error to track down, because color-coded editors won&#8217;t help you out here: you could just as easily purposefully name an element &#8220;navigaiton&#8221; if you really wanted. But I&#8217;d recommend against it.</p>
<h3>Improperly Ordered Values</h3>
<p>Some CSS properties have a built-in shorthand, which is a great way to save yourself a few lines of code. Unfortunately, most of the shorthand properties are very picky about the order of the property&#8217;s values. For example:</p>
<pre class="css">div { font: 2em Helvetica, Arial, sans-serif; }
a { font: "Times New Roman", serif 1.5em; }</pre>
<p>The first rule will result in all divs gaining a specific typeface and size. The second rule will result in a debugging session &mdash; while it&#8217;s okay to leave some values out of the font declaration, changing up the order of the values will result in problems.</p>
<h3>Measurement Values Without Units</h3>
<p>CSS Newbie reader Justin reminded me of this problem <a href="http://www.cssnewbie.com/five-quick-css-fixes/">the last time I wrote about CSS faux pas.</a> With only a few limited exceptions, all measurement values in CSS need a unit of measurement associated with it. Take the following rule for example:</p>
<pre class="css">#wrap { margin: 3; }</pre>
<p>Three <em>what</em>? Ems? Inches? Pizzles? The flexibility of CSS that allows us to pick from several units of measurement also means specifying a unit is fairly important.</p>
<h4>Bonus &mdash; Two unit-agnostic measurements:</h4>
<ol>
<li>Values of zero don&#8217;t need a unit of measurement. Turns out, zero pixels and zero miles are <em>exactly the same length.</em></li>
<li>Line heights needn&#8217;t have a specific unit. A line height of &#8220;1.5&#8243;, for example, will simply assume you meant &#8220;1.5 times my font size.&#8221; For more on this phenomenon, <a href="http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/">visit Eric Meyer&#8217;s article on Unitless Line Heights.</a></li>
</ol>
<h3>Competing Identical Rules</h3>
<p>Once a stylesheet gets to be a certain length, it can be difficult to remember which rules you&#8217;ve already written <a href="http://www.cssnewbie.com/organized-style-sheet/">unless your CSS is very well organized.</a> And two identical rules at different spots in your CSS file can wreak havoc on your design and sanity alike.</p>
<pre class="css">ul li { margin: 0 2em; }
... 300 lines later ...
ul li { margin: 0; padding: 10px; }</pre>
<p>In this scenario, the latter rule would win out over the former, thus removing the margin and applying padding instead. But if you&#8217;ve forgotten about this duplicity, you might go back into your CSS later and try editing the <em>first</em> rule only, and remain perplexed as to why, no matter how you tweak your margin, you can&#8217;t seem to make any difference.</p>
<h3>Unintentionally Competing Rules</h3>
<p>A similar problem could force your CSS to compete with itself in ways you didn&#8217;t expect. For example, if you had the following code in your XHTML:</p>
<pre class="html">&lt;div id="navigation" class="nav"&gt;...&lt;/div&gt;</pre>
<p>You could refer to this element by either its class or its ID. The problem arises when you do both, and forget that you&#8217;ve done so:</p>
<pre class="css">.nav { width: 50%; }
... later in the code ...
#navigation { width: 500px; }</pre>
<p>This code would result in a fixed-width navigation bar, even though the first rule would suggest a more flexible width. Again, <a href="http://www.cssnewbie.com/organized-style-sheet/">having a well organized stylesheet</a> is the easiest way to avoid this problem.</p>
<h3>Calling a Class an ID (or vice-versa)</h3>
<p>I fall into this particular trap all the time. I&#8217;ll write a rule like this: </p>
<pre class="css">.navigation {
	float: left;
	width: 100%;
	height: 4em; }</pre>
<p>And nothing will happen! It often takes me a minute or two to realize that the real problem is that I&#8217;d given my navigation bar an ID, not a class. My best advice here is to pick a naming system that works well for you and <strong>be consistent.</strong> If you always call your top navigation bar &#8220;#topnav&#8221;, for example, you&#8217;re far less likely to misremember your element names.</p>
<h3>Using a Nonexistent Property</h3>
<p>Not all CSS properties are named the most intuitively. For example, this might look like a perfectly acceptable rule to someone new to CSS:</p>
<pre class="css">body { text-size: 3em; }</pre>
<p>The problem is, while there are certainly several text-riffic properties, text-size isn&#8217;t one of them. Instead, we use font-size. Which means that the rule above wouldn&#8217;t do much of anything. <a href="http://www.amazon.com/gp/product/B001EUDIZE?ie=UTF8&#038;tag=cssnewbie-20&#038;linkCode=as2&#038;camp=1789&#038;creative=390957&#038;creativeASIN=B001EUDIZE">Intelligent code-coloring editors like Dreamweaver</a> usually make this sort of debugging much easier: if it&#8217;s not a real CSS property, it won&#8217;t be the same color as the surrounding properties. That&#8217;s usually my first clue I&#8217;ve done something wrong.</p>
<h3>Using a Nonexistent Value</h3>
<p>This is a sister stumbling block to the one above. Some values just seem to make sense, but will fail you nonetheless:</p>
<pre class="css">td { vertical-align: center; }</pre>
<p>You would assume that this rule would vertically center your table text, right? Unfortunately, while &#8220;center&#8221; is indeed an acceptable value for text-align, vertical-align uses the perhaps less intuitive &#8220;middle&#8221; instead. And you&#8217;d have to ask a better educated rhetorician than me to figure out the difference between middle and center in this context, because I&#8217;m at a loss.</p>
<h3>Improperly Matching Properties and Values</h3>
<p>Certain CSS declarations can look correct even to the trained eye, unless that eye is paying particularly close attention. For example:</p>
<pre class="css">a { text-transform: italic; }</pre>
<p>While this might look like a perfectly reasonable rule, you won&#8217;t end up with italicized text. That&#8217;s because &#8220;italic&#8221; belongs to the font-style property, not the text-transform property. But even most advanced editors won&#8217;t catch that bug, as you&#8217;ve used a perfectly reasonable property and value &mdash; you&#8217;ve just used them in an inappropriate combination.</p>
<h3>Not Closing Comments</h3>
<p>The <a href="http://blogthememachine.com/">gentle persons at BlogThemeMachine</a> tipped me off to this common CSS problem. Can you spot the major difference between these two sets of rules?</p>
<pre class="css">/* Navigation goes here. */
#nav {
	float: left;
	width: 100%;
	height: 3em; }</pre>
<pre class="css">/* Navigation goes here. /*
#nav {
	float: left;
	width: 100%;
	height: 3em; }</pre>
<p>The only difference is that the second rule has an improperly closed comment tag: /* versus */. That seemingly insignificant difference can result in entire swaths of your CSS suddenly not working. In fact, this tiny blunder will negate all your CSS from the start of your comment until you successfully close a <em>second</em> comment. Which if you&#8217;re using comments to organize your CSS means an entire section of your site will lose its styling.</p>
<p>These fifteen tiny blunders are sure to give you hours upon hours of CSS frustration&#8230; unless you know to watch for them. What are some other self-introduced bugs you often find in your code? I&#8217;d love to hear about them in the comments!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ib8CLW9iaO8:lXo3OCxcFq0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ib8CLW9iaO8:lXo3OCxcFq0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ib8CLW9iaO8:lXo3OCxcFq0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ib8CLW9iaO8:lXo3OCxcFq0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ib8CLW9iaO8:lXo3OCxcFq0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ib8CLW9iaO8:lXo3OCxcFq0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ib8CLW9iaO8:lXo3OCxcFq0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ib8CLW9iaO8:lXo3OCxcFq0:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=ib8CLW9iaO8:lXo3OCxcFq0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=ib8CLW9iaO8:lXo3OCxcFq0:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/ib8CLW9iaO8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/15-surefire-ways-to-break-your-css/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/15-surefire-ways-to-break-your-css/</feedburner:origLink></item>
		<item>
		<title>New Poll: How Much CSS Do You Already Know?</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/jGl_bkFCdNA/</link>
		<comments>http://www.cssnewbie.com/new-poll-how-much-css-do-you-already-know/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 14:21:05 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Polls]]></category>

		<category><![CDATA[Site News]]></category>

		<category><![CDATA[articles]]></category>

		<category><![CDATA[newbie]]></category>

		<category><![CDATA[poll]]></category>

		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=397</guid>
		<description><![CDATA[I've posted a new poll in the footer of the website, and I'd appreciate if you'd take a second or two and answer the question: how much CSS do you already know? This is a chance for me to get to know you a little bit better. It will also help me to produce the sort of content that you would find most useful.]]></description>
			<content:encoded><![CDATA[<p>Hey everyone, I&#8217;ve posted a new poll in the footer of the website, and I&#8217;d appreciate if you&#8217;d take a second or two (literally) and answer the question du jour: how much CSS do you already know?</p>
<p>This is a chance for me to get to know you, my audience, a little bit better. It will also help me do my darnedest to produce the sort of content that you would find most useful. So! Are you a true CSS newbie, already a big deal in the CSS world, or somewhere in between? Let me know in the poll below!</p>
<p>Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.<span id="more-397"></span></p>
<p>Also, here are the results from the last poll, which asked, &#8220;what do you want to see on CSS Newbie in 2009?&#8221;:</p>
<ul>
<li><strong>59%</strong> of the voters wanted <strong>more long, tutorial-style articles</strong>.</li>
<li><strong>43.4%</strong> wanted <strong>more short, quick tip articles.</strong></li>
<li><strong>33.7%</strong> requested <strong>more entry-level, CSS-specific articles</strong>.</li>
<li><strong>31.3%</strong> wanted <strong>more advanced and non-CSS articles</strong>.</li>
<li><strong>24.1%</strong> wanted to see <strong>video tutorials and tips</strong>.</li>
<li><strong>19.3%</strong> were looking for <strong>a forum to help find solutions</strong>.</li>
<li><strong>12%</strong> wanted <strong>an email newsletter to stay in touch</strong>.</li>
</ul>
<p><em>(note: these add up to more than 100% because people could choose more than one option)</em></p>
<p>So obviously, the overwhelming answer is: more articles! Long, short, entry-level, and advanced&#8230; it seems there&#8217;s an audience for all four. And since I try to offer a combination of all four currently, that is a very encouraging result to see. And the other three &#8212; video tutorials, forums, and an email newsletter &#8212; were all desired by more than 10% of the respondents. Obviously I have a lot of planning to do!</p>
<p>So thanks everyone for participating in the last poll, and please take a second to give me your responses on this one!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=jGl_bkFCdNA:dolRC0KFVk4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=jGl_bkFCdNA:dolRC0KFVk4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=jGl_bkFCdNA:dolRC0KFVk4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=jGl_bkFCdNA:dolRC0KFVk4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=jGl_bkFCdNA:dolRC0KFVk4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=jGl_bkFCdNA:dolRC0KFVk4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=jGl_bkFCdNA:dolRC0KFVk4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=jGl_bkFCdNA:dolRC0KFVk4:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=jGl_bkFCdNA:dolRC0KFVk4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=jGl_bkFCdNA:dolRC0KFVk4:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/jGl_bkFCdNA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/new-poll-how-much-css-do-you-already-know/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/new-poll-how-much-css-do-you-already-know/</feedburner:origLink></item>
		<item>
		<title>Build Custom Frameworks Easily with CSS Classes</title>
		<link>http://feedproxy.google.com/~r/cssnewbie/~3/tnYaQWMZqgo/</link>
		<comments>http://www.cssnewbie.com/build-custom-frameworks/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 22:00:03 +0000</pubDate>
		<dc:creator>Rob Glazebrook</dc:creator>
		
		<category><![CDATA[Basic Techniques]]></category>

		<category><![CDATA[Frameworks and Libraries]]></category>

		<category><![CDATA[IDs and Classes]]></category>

		<category><![CDATA[Layout]]></category>

		<category><![CDATA[css]]></category>

		<category><![CDATA[custom]]></category>

		<category><![CDATA[framework]]></category>

		<category><![CDATA[xhtml]]></category>

		<guid isPermaLink="false">http://www.cssnewbie.com/?p=388</guid>
		<description><![CDATA[Generally speaking, I consider full-fledged CSS frameworks to be overkill. However, I still think that the foundation on which CSS frameworks are built &#8212; the concept of using classes to simplify layout and standardize design across similar elements &#8212; is very much worth investigation.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.woodsmithshop.com/?from=cssnewbie"><img src="http://www.cssnewbie.com/wp-content/uploads/2009/03/column-wsshop.jpg" alt="Woodsmith Shop columns" title="Woodsmith Shop columns" width="579" height="200" class="alignnone size-full wp-image-389" /></a></p>
<p>Generally speaking, I consider full-fledged CSS frameworks to be overkill on all but the most absolutely complex projects or, on the other end of the spectrum, rapid proof-of-concept prototyping. Most people only use a few of the classes that any one CSS framework provides, but then still require their users to download the entire, and largely unused, stylesheet.</p>
<p>However, I still think that the foundation on which CSS frameworks are built &mdash; the concept of using classes to simplify layout and standardize design across similar elements &mdash; is very much worth investigation. But instead of relying on a one-size-fits-all (snuggie-esque?) solution, I&#8217;d encourage you to take a few minutes and build a custom, simplified framework that does exactly what you need it to do.<span id="more-388"></span></p>
<h3>The Back Story</h3>
<p>I recently built a website based on a fairly regular, consistent grid. The content area was 780px wide and would contain six &#8220;columns&#8221; of content with 12-pixel gutters between each of the columns, though various elements could span one or more of those columns. </p>
<p><img src="http://www.cssnewbie.com/wp-content/uploads/2009/03/column-examples.png" alt="sample content layouts in a six-column grid" title="sample content layouts in a six-column grid" width="579" height="200" class="alignnone size-full wp-image-390" /></p>
<p>Because of the general flexibility of the content combined with the rigidity of the columnar structure, my mind immediately jumped to frameworks as a way to get this design pushed out in a hurry. But in the end, I just couldn&#8217;t justify all that overhead, even to create a flexible six-column design. So instead, I decided to write my own mini-framework to do only what I needed.</p>
<h3>The Custom Framework</h3>
<p>Here&#8217;s the basic CSS I ended up writing:</p>
<pre class="css">.col {
	float: left; }
.gutter {
	margin-right: 12px; }
.span1 {
	width: 120px; }
.span2 {
	width: 252px; }
.span3 {
	width: 384px; }
.span4 {
	width: 516px; }
.span5 {
	width: 648px; }
.span6 {
	width: 780px; }
.clear {
	clear: left; }</pre>
<p>Pretty simple stuff, right? All it contains is nine classes that I can arbitrarily assign to my structural divs to determine how the page will lay out. The first class, &#8220;col&#8221;, gets assigned to any div I want to behave like a column. </p>
<p>Then each column is given one of the &#8220;span&#8221; classes (using <a href="http://www.cssnewbie.com/css-rules-multiplicity/">the benefit of multiple CSS classes to great effect</a>) to determine its width &mdash; or as I thought of it at the time, the number of columns the div would span&#8230; just like using &#8220;colspan&#8221; in old-school table layouts. </p>
<p>Next up we have the &#8220;gutter&#8221; class, which I add to any column that should have a gutter along its right edge (which would be true for all columns except those along the very right edge of my content area). And finally, there&#8217;s a &#8220;clear&#8221; class, just to ensure that my divs behave themselves even if I didn&#8217;t entirely fill up the previous &#8220;row&#8221; of divs.</p>
<h3>The XHTML Structure</h3>
<p>There&#8217;s not much to the XHMTL structure for my custom framework. Essentially, it&#8217;s a bunch of divs given two or more of my nine classes to determine its behavior. For example, to create the 4-2/2-1-3 structure I highlighted in the image above, this would be the structure:</p>
<pre class="html">&lt;div class=&quot;col span4 gutter&quot;&gt;Four columns&lt;/div&gt;
&lt;div class=&quot;col span2&quot;&gt;Two columns here&lt;/div&gt;
&lt;div class=&quot;col span2 gutter&quot;&gt;Two cols and a gutter&lt;/div&gt;
&lt;div class=&quot;col span1 gutter&quot;&gt;Only 120px!&lt;/div&gt;
&lt;div class=&quot;col span3&quot;&gt;Three columns.&lt;/div&gt;</pre>
<p>If you&#8217;d like to see this sort of custom framework in action, it&#8217;s running on <a href="http://www.woodsmithshop.com/?from=cssnewbie">the website for the Woodsmith Shop TV show.</a></p>
<h3>One Size Doesn&#8217;t Fit All</h3>
<p>Now, I&#8217;m not saying my framework is the end-all CSS framework and that you should just copy it wholesale into your own project and expect it to work perfectly. The idea here is to take this concept and come up with a custom framework that works perfectly for <em>your needs</em>. </p>
<p>The real take-away lesson here is that for most projects, you don&#8217;t need dozens of classes and hundreds of lines of CSS just to create a flexible grid structure. I created mine with just nine CSS classes and it was sufficient to power my six-column grid. I&#8217;d be interested to see what other people (namely, you) have come up with along these same lines. Share a link in the comments!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/cssnewbie?a=tnYaQWMZqgo:wQEuYOLiEro:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=tnYaQWMZqgo:wQEuYOLiEro:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=tnYaQWMZqgo:wQEuYOLiEro:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=tnYaQWMZqgo:wQEuYOLiEro:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=tnYaQWMZqgo:wQEuYOLiEro:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=tnYaQWMZqgo:wQEuYOLiEro:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=tnYaQWMZqgo:wQEuYOLiEro:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=tnYaQWMZqgo:wQEuYOLiEro:l6gmwiTKsz0"><img src="http://feeds.feedburner.com/~ff/cssnewbie?d=l6gmwiTKsz0" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/cssnewbie?a=tnYaQWMZqgo:wQEuYOLiEro:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/cssnewbie?i=tnYaQWMZqgo:wQEuYOLiEro:D7DqB2pKExk" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/cssnewbie/~4/tnYaQWMZqgo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.cssnewbie.com/build-custom-frameworks/feed/</wfw:commentRss>
		<feedburner:origLink>http://www.cssnewbie.com/build-custom-frameworks/</feedburner:origLink></item>
	</channel>
</rss>
