<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Justin Tadlock &#187; XHTML</title>
	<atom:link href="http://justintadlock.com/tags/xhtml/feed" rel="self" type="application/rss+xml" />
	<link>http://justintadlock.com</link>
	<description>Life, Blogging, and WordPress</description>
	<lastBuildDate>Mon, 06 Feb 2012 18:39:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How To Create Tabs Using jQuery</title>
		<link>http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery</link>
		<comments>http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery#comments</comments>
		<pubDate>Wed, 07 Nov 2007 22:15:54 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[Web Design]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery</guid>
		<description><![CDATA[Tabbed sidebar elements are in. Why bother making users scroll down the page, when they can simply click a tab to quickly access various parts of your site? Another popular thing is jQuery, &#8220;The Write Less, Do More, JavaScript Library.&#8221; I&#8217;ve gotten a lot of emails asking how I created tabs with jQuery in the [...]]]></description>
			<content:encoded><![CDATA[<p>Tabbed sidebar elements are in.  Why bother making users scroll down the page, when they can simply click a tab to quickly access various parts of your site?  Another popular thing is <a href="http://jquery.com" title="jQuery javascript library"> jQuery</a>, &#8220;The Write Less, Do More, JavaScript Library.&#8221;</p>
<p>I&#8217;ve gotten a lot of emails asking how I created tabs with jQuery in the last couple of days &mdash; since I released the <a href="http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery" title="Visionary WordPress theme: A theme for magazine and news sites"> Visionary theme</a>.  It&#8217;s actually not all that hard (I&#8217;m not a JavaScript programmer), and I&#8217;m going to run you through a tutorial.</p>
<p>This tutorial is primarily based off WordPress, but can easily be ported anywhere else.</p>
<p>First, you&#8217;ll need four files.  You need &#8220;sidebar.php,&#8221; &#8220;header.php,&#8221; &#8220;style.css,&#8221; and &#8220;tabs.js&#8221; (you&#8217;ll have to create this file).  Then, you need to download a copy of <a href="http://jquery.com" title="jQuery javascript library"> jQuery</a>.  This file will be named &#8220;jquery.js.&#8221;  Add it to your theme directory along with each of these other files.</p>
<h3>Pulling the jQuery into your blog:</h3>
<p>Open &#8220;header.php&#8221; and add these lines between the <code>&lt;head&gt;&lt;/head&gt;</code> tags:</p>
<pre><code>&lt;script type="text/javascript" src="&lt;?php echo bloginfo(stylesheet_directory) .'/jquery.js'; ?&gt;"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="&lt;?php echo bloginfo(stylesheet_directory) .'/tabs.js'; ?&gt;"&gt;&lt;/script&gt;</code></pre>
<p>Now, you can close that file.  You won&#8217;t need it anymore.  All this does is include jQuery and our custom script on every page of your site.  You can now use them anywhere.</p>
<h3>Creating the sidebar:</h3>
<p>First, we need to open &#8220;sidebar.php&#8221; and input this code.  This is the XHTML we&#8217;re using.  I&#8217;m leaving the content inside the tabs open.  Do what you want with it.  You shouldn&#8217;t change the specific classes used because we&#8217;ll need them when using jQuery.  If you change them here, you&#8217;ll have to change them in your &#8220;tabs.js&#8221; file.</p>
<pre><code>
&lt;div class="tabbed"&gt;
	&lt;!-- The tabs --&gt;
	&lt;ul class="tabs"&gt;
	&lt;li class="t1"&gt;&lt;a class="t1 tab" title="&lt;?php _e('Tab 1'); ?&gt;"&gt;&lt;?php _e('Tab 1'); ?&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class="t2"&gt;&lt;a class="t2 tab" title="&lt;?php _e('Tab 2'); ?&gt;"&gt;&lt;?php _e('Tab 2'); ?&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class="t3"&gt;&lt;a class="t3 tab" title="&lt;?php _e('Tab 3'); ?&gt;"&gt;&lt;?php _e('Tab 3'); ?&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;li class="t4"&gt;&lt;a class="t4 tab" title="&lt;?php _e('Tab 4'); ?&gt;"&gt;&lt;?php _e('Tab 4'); ?&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;

	&lt;!-- tab 1 --&gt;
	&lt;div class="t1"&gt;
	&lt;!-- Put what you want in here.  For the sake of this tutorial, we'll make a list.  --&gt;
	&lt;ul&gt;
		&lt;li&gt;List item&lt;/li&gt;
		&lt;li&gt;List item&lt;/li&gt;
		&lt;li&gt;List item&lt;/li&gt;
		&lt;li&gt;List item&lt;/li&gt;
		&lt;li&gt;List item&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/div&gt;

	&lt;!-- tab 2 --&gt;
	&lt;div class="t2"&gt;
	&lt;!-- Or, we could put a paragraph --&gt;
		&lt;p&gt;This is a paragraph about the jQuery tabs tutorial.&lt;/p&gt;
	&lt;/div&gt;

	&lt;!-- tab 3 --&gt;
	&lt;div class="t3"&gt;
	&lt;!-- Or, we could add a div --&gt;
		&lt;div&gt;Something needs to go in here!&lt;/div&gt;
	&lt;/div&gt;

	&lt;!-- tab 4 --&gt;
	&lt;div class="t4"&gt;
	&lt;!-- Why not put a few images in here? --&gt;
		&lt;p&gt;
			&lt;img src="image.gif" alt="Sample" /&gt;
			&lt;img src="image.gif" alt="Sample" /&gt;
			&lt;img src="image.gif" alt="Sample" /&gt;
		&lt;/p&gt;
	&lt;/div&gt;

&lt;/div&gt;&lt;!-- tabbed --&gt;</code></pre>
<p>Now, our sidebar is set up.  You can close &#8220;sidebar.php.&#8221;</p>
<h3>The backbone, jQuery:</h3>
<p>Open, or create, the file &#8220;tabs.js&#8221; for this part of the tutorial.  This is the heart of our script.  I&#8217;m sure there&#8217;s a better way to do this, but since so many people have requested this, they&#8217;ll have to stick with my version I guess.  Copy and paste this code into your file.</p>
<p><strong>Updated:</strong> Thanks to Karl from <a href="http://learningjquery.com" title="Learning jQuery"> Learning jQuery</a> for providing better code for this.</p>
<pre><code>$(document).ready(function() {
// setting the tabs in the sidebar hide and show, setting the current tab
	$('div.tabbed div').hide();
	$('div.t1').show();
	$('div.tabbed ul.tabs li.t1 a').addClass('tab-current');

// SIDEBAR TABS
$('div.tabbed ul li a').click(function(){
	var thisClass = this.className.slice(0,2);
	$('div.tabbed div').hide();
	$('div.' + thisClass).show();
	$('div.tabbed ul.tabs li a').removeClass('tab-current');
	$(this).addClass('tab-current');
	});
});</code></pre>
<p>You can close this file once you&#8217;re finished pasting the above code in.</p>
<h3>Styling the sidebar:</h3>
<p>Since I can&#8217;t decide how to style your sidebar for you, I&#8217;ll just leave you with things styled enough to get your started.  Of course, you can do anything you want with styling.  The tabbed sidebar has a lot of different classes that you can make use of.  Or, you can even add your own.  Use this code in your &#8220;style.css&#8221; file.  Make adjustments to suit your needs.</p>
<pre><code>/* Contains the entire tabbed section */
.tabbed {
	}

/* List of tabs */.tabbed ul.tabs {
	float: left;
	display: inline;
	width: 100%;
	margin: 0;
	padding: 0;
	}
.tabbed ul.tabs li {
	list-style: none;
	float: left;
	margin: 0;
	padding: 0;
	}
.tabbed ul.tabs li a {
	overflow: hidden;
	display: block;
	margin: 0 2px 0 0;
	padding: 10px 12px;
	}
.tabbed ul.tabs li a:hover {
	}

/* The current selected tab */
.tabbed ul.tabs li a.tab-current {
	}

/* The content shown when a tab is selected */
.tabbed div {
	float: left;
	display: block;
	width: 100%;
	}

/* Set the CSS to make sure the other tabs' content isn't shown other than the first */
.tabbed div.t2, .tabbed div.t3, .tabbed div.t4 {
	display: none;
	}

/* Content for inside your tabs' divs */
.tabbed div ul {
	}
.tabbed div p {
	}
.tabbed div div {
	}</code></pre>
<p>There you have it.  It seems like a good bit of code, but it really isn&#8217;t too bad.  Most of the stuff you won&#8217;t have to touch too often.  Just get everything set up and style it.</p>
<p>I hope this helps, and if you find any bugs, make sure to report them.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2007/11/07/how-to-create-tabs-using-jquery/feed</wfw:commentRss>
		<slash:comments>101</slash:comments>
		</item>
		<item>
		<title>Valid XHTML Clickable Header Images</title>
		<link>http://justintadlock.com/archives/2007/10/22/valid-xhtml-clickable-header-images</link>
		<comments>http://justintadlock.com/archives/2007/10/22/valid-xhtml-clickable-header-images#comments</comments>
		<pubDate>Mon, 22 Oct 2007 15:09:29 +0000</pubDate>
		<dc:creator>Justin Tadlock</dc:creator>
				<category><![CDATA[WordPress]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://justintadlock.com/archives/2007/10/22/valid-xhtml-clickable-header-images</guid>
		<description><![CDATA[This is a tutorial on how to make your blog or website header image clickable with valid XHTML. This is assuming that you&#8217;re using a CSS background image for your header or that you want to. I was recently designing a theme that I wanted to add a clickable header image to, but had forgotten [...]]]></description>
			<content:encoded><![CDATA[<p><img class="center" src="http://justintadlock.com/wp-content/uploads/2007/10/clickable-header.gif" alt="Valid XHTML clickable header images" title="Valid XHTML clickable header images" /></p>
<p>This is a tutorial on how to make your blog or website header image clickable with valid XHTML.  This is assuming that you&#8217;re using a CSS background image for your header or that you want to.</p>
<p>I was recently designing a theme that I wanted to add a clickable header image to, but had forgotten the best way to accomplish this task.  So, I quickly searched Google and thought I found an easy way to do this with the <a href="http://codex.wordpress.org/Designing_Headers#Making_the_Whole_Header_Clickable" title="WordPress Codex: Making the whole header clickable"> WordPress clickable header tutorial</a>, but quickly realized that it wasn&#8217;t valid XHTML.  Many other tutorials showed this same example as well.</p>
<p>Basically, they were wrapping the <code> &lt;a&gt;</code> element around the <code> &lt;h1&gt;</code> element.  This is bad.  Very bad.  CSS can do so much.  Why ruin its beauty with poorly structured HTML?</p>
<p>After playing around with the CSS for a while, I came up with a solution.</p>
<p>First, you obviously need a header image.  For the sake of this tutorial, the width and height of this image will be 350px by 90px.  You can change the values in the CSS to match with your header image.  Add this code to your header file or wherever your header image will go.</p>
<h3>XHTML</h3>
<pre><code>&lt;div id="header"&gt;
&lt;h1&gt;
&lt;a href="/index.php" title="Blog Title"&gt;&lt;span>Blog Title&lt;/span&gt;&lt;/a&gt;
&lt;/h1&gt;
&lt;/div&gt;</code></pre>
<p>Now, we need to style this thing.</p>
<h3>CSS</h3>
<pre><code>#header {
	float: left;
	width: 100%;
	}
#header h1 {
	float: left;
	margin: 0;
	padding: 0;
	width: 350px;
	}
#header h1 a {
	padding: 0;
	margin: 0;
	width: 350px;
	height: 90px;
	display: block;
	background: url(images/header1.gif) no-repeat top left;
	}
#header h1 a span { display: none; }</code></pre>
<p>These CSS values aren&#8217;t going to be exact all the time.  Some things can change depending on your layout.  Your positioning, height, width, margin, and padding are all variables that may need to change.  The most important things are these lines:</p>
<pre><code>#header h1 a {
	width: 350px;
	height: 90px;
	display: block;
	background: url(images/header1.gif) no-repeat top left;
	}</code></pre>
<p>Giving the link (which has a background image) a width, height, block display, and adding the image are the things you must do.</p>
<p>That should pretty much do it.  If you have any problems, please let me know through the <a href="http://justintadlock.com/forums" title="Support forums"> support forums</a>.  Otherwise, enjoy using your valid XHTML clickable header image.</p>
<p>You can also use this technique to make any element clickable with a background image, not just header images.</p>
]]></content:encoded>
			<wfw:commentRss>http://justintadlock.com/archives/2007/10/22/valid-xhtml-clickable-header-images/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

