<?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>Kyle Schaeffer - Web Design and SharePoint Branding &#187; DHTML</title>
	<atom:link href="http://kyleschaeffer.com/tag/dhtml/feed/" rel="self" type="application/rss+xml" />
	<link>http://kyleschaeffer.com</link>
	<description>Web Design &#38; SharePoint Branding</description>
	<lastBuildDate>Wed, 01 Feb 2012 23:01:50 +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>Create a Lightbox with jQuery and CSS</title>
		<link>http://kyleschaeffer.com/tutorials/lightbox-jquery-css/</link>
		<comments>http://kyleschaeffer.com/tutorials/lightbox-jquery-css/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:37:05 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=488</guid>
		<description><![CDATA[The &#8220;lightbox&#8221; is a unique and useful design tool when used properly. It allows designers to present information that is totally independent from the site theme, and it is especially useful when displaying information that is loaded via AJAX requests &#8230; <a href="http://kyleschaeffer.com/tutorials/lightbox-jquery-css/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The &#8220;lightbox&#8221; is a unique and useful design tool when used properly. It allows designers to present information that is totally independent from the site theme, and it is especially useful when displaying information that is loaded via AJAX requests (often negating the need for additional post-backs on your pages). There are countless ways to implement lightbox functionality into your site, and almost every option I&#8217;ve ever seen is weighed down by extraneous functionality or useless transition animations. It&#8217;s quite easy to create your own lightboxes with minimal effort. This tutorial can serve as a quick and easy template to get you started.<span id="more-488"></span></p>
<h2>The CSS Style</h2>
<p>There are <em>two</em> elements you&#8217;ll have to implement into your design in order to create a lightbox — CSS and Javascript. We&#8217;ll take care of the CSS style first, as it&#8217;s the most simple to implement. On your page or in an attached style sheet, add the following CSS styles:</p>
<pre>#lightbox {
	position: absolute;
	top: 0;
	left: 50%;
	width: 500px;
	margin-left: -250px;
	background: #fff;
	z-index: 1001;
	display: none;
}
#lightbox-shadow {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: #000;
	filter: alpha(opacity=75);
	-moz-opacity: 0.75;
	-khtml-opacity: 0.75;
	opacity: 0.75;
	z-index: 1000;
	display: none;
}</pre>
<p><strong>What we just did:</strong> we established two styles. One style is for the lightbox that actually appears on the page (<code>#lightbox</code>). The second style is for lightbox background (<code>#lightbox-shadow</code>). We have made this background dark and semi-transparent in order to dim the site&#8217;s content as it appears behind the lightbox.</p>
<h2>The jQuery Script</h2>
<p>The real work is done via our simple jQuery script. We have two JavaScript functions that will handle displaying and hiding our lightbox. First, make sure you have attached the jQuery library to your page:</p>
<pre>&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;</pre>
<p>Now, in an attached <code>.js</code> file, add the following script code.</p>
<pre>/****************************************
	Barebones Lightbox Template
	by Kyle Schaeffer
	kyleschaeffer.com
	* requires jQuery
****************************************/

// display the lightbox
function lightbox(insertContent, ajaxContentUrl){

	// add lightbox/shadow &lt;div/&gt;'s if not previously added
	if($('#lightbox').size() == 0){
		var theLightbox = $('&lt;div id=&quot;lightbox&quot;/&gt;');
		var theShadow = $('&lt;div id=&quot;lightbox-shadow&quot;/&gt;');
		$(theShadow).click(function(e){
			closeLightbox();
		});
		$('body').append(theShadow);
		$('body').append(theLightbox);
	}

	// remove any previously added content
	$('#lightbox').empty();

	// insert HTML content
	if(insertContent != null){
		$('#lightbox').append(insertContent);
	}

	// insert AJAX content
	if(ajaxContentUrl != null){
		// temporarily add a &quot;Loading...&quot; message in the lightbox
		$('#lightbox').append('&lt;p class=&quot;loading&quot;&gt;Loading...&lt;/p&gt;');

		// request AJAX content
		$.ajax({
			type: 'GET',
			url: ajaxContentUrl,
			success:function(data){
				// remove &quot;Loading...&quot; message and append AJAX content
				$('#lightbox').empty();
				$('#lightbox').append(data);
			},
			error:function(){
				alert('AJAX Failure!');
			}
		});
	}

	// move the lightbox to the current window top + 100px
	$('#lightbox').css('top', $(window).scrollTop() + 100 + 'px');

	// display the lightbox
	$('#lightbox').show();
	$('#lightbox-shadow').show();

}

// close the lightbox
function closeLightbox(){

	// hide lightbox and shadow &lt;div/&gt;'s
	$('#lightbox').hide();
	$('#lightbox-shadow').hide();

	// remove contents of lightbox in case a video or other content is actively playing
	$('#lightbox').empty();
}</pre>
<link rel="stylesheet" type="text/css" href="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/03/lightbox.css" />
<style type="text/css">#lightbox-shadow { position: fixed; } #lightbox { font-size: 2em; padding: 20px; margin-left: -270px; }</style>
<p><script type="text/javascript" src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/03/lightbox.js"></script><br />
<h2>Ready for Lightboxing</h2>
<p>Once you have the CSS and script into place, you can call your new <code>lightbox();</code> function from anywhere within your design. It&#8217;s as easy as calling the lightbox from an <code>anchor</code> tag:</p>
<pre>&lt;a href=&quot;javascript:lightbox('Hello!');&quot;&gt;Show me the lightbox&lt;/a&gt;</pre>
<p>Remember, clicking anywhere on the &#8220;shadow&#8221; <code>&lt;div/&gt;</code> will hide the lightbox &mdash; you could easily add a &#8220;close&#8221; button to your lightbox by connecting it to the <code>closeLightbox();</code> JavaScript function.</p>
<p>Similarly, you can insert HTML (or even a jQuery DOM object) into the lightbox. Like so:</p>
<pre>&lt;a href=&quot;javascript:lightbox('&lt;p&gt;&lt;strong&gt;Rich&lt;/strong&gt; content works too!&lt;/p&gt;');&quot;&gt;Show me the lightbox&lt;/a&gt;</pre>
<p>Finally, you can even use this simple lightbox function to insert AJAX content. Please keep in mind that my JavaScript function simply inserts the entire result into the <code>#lightbox</code> element &mdash; if you&#8217;re trying to request a website or HTML page, you&#8217;ll probably have to remove the <code>&lt;html/&gt;</code> and <code>&lt;body/&gt;</code> tags before inserting content into your lightbox window, else the lightbox would simply disappear. An AJAX lightbox request looks a little like this:</p>
<pre>&lt;a href=&quot;javascript:lightbox(null, 'http://foo.com/readme.txt');&quot;&gt;Show me the lightbox&lt;/a&gt;</pre>
<h2>The Demo</h2>
<ul>
<li><strong>Try it out:</strong> <a href="javascript:lightbox('How elegantly simple! This is a barebones lightbox if I ever saw one. Click on the dark shaded background to close the lightbox.');">Show me the lightbox</a></li>
<li><strong>Let&#8217;s load some AJAX content:</strong> <a href="javascript:lightbox(null, 'http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/03/lightbox.css');">Load the CSS file for this tutorial into a lightbox</a></li>
</ul>
<p>If you&#8217;re on a fast connection, you may not notice, but the AJAX link actually reads &#8220;Loading&#8230;&#8221; in the lightbox a split-second before the content actually appears.  This can be useful to give users feedback while the AJAX request is processing. Please note that I&#8217;ve added a bit of styling to my demo (namely padding on the lightbox to make it appear less cluttered).</p>
<h2>Make it Shine</h2>
<p>You&#8217;ll probably want to modify the CSS and other elements of this lightbox in order to suit your site&#8217;s design and style. If you&#8217;re working with a lot of AJAX content, you may want to even replace the temporary <code>loading</code> element with an animated spinner image, or something of the like.</p>
<p>To help you get started, you can download the CSS and JavaScript referenced in this tutorial here:</p>
<ul>
<li><a href="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/03/lightbox.css">lightbox.css</a></li>
<li><a href="http://kyleschaeffer.com/wordpress/wp-content/uploads/2010/03/lightbox.js">lightbox.js</a></li>
</ul>
<p>Good luck, and happy styling!</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/tutorials/lightbox-jquery-css/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>A Simple jQuery Tabs Template</title>
		<link>http://kyleschaeffer.com/web-controls/simple-jquery-tabs-template/</link>
		<comments>http://kyleschaeffer.com/web-controls/simple-jquery-tabs-template/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 14:47:28 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Web Controls]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Tabs]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=348</guid>
		<description><![CDATA[I love jQuery; I use it all the time. I also love the great UI controls that come with the jQuery UI library. Unfortunately, I&#8217;ve found that a lot of these controls can be a little heavy in terms of &#8230; <a href="http://kyleschaeffer.com/web-controls/simple-jquery-tabs-template/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I love <a href="http://jquery.com/">jQuery</a>; I use it all the time. I also love the great UI controls that come with the <a href="http://jqueryui.com/">jQuery UI</a> library. Unfortunately, I&#8217;ve found that a lot of these controls can be a little heavy in terms of required JS/CSS files that your clients will have to download in order to use these controls. Being the minimalist that I am, I really want to drop a small amount of CSS and HTML into my site and quickly get myself up and running with a tab structure that&#8217;s both flexible and accessible.<span id="more-348"></span></p>
<h2>Adding jQuery is Easy</h2>
<p>You&#8217;ll need to include a few JavaScript libraries in order to use jQuery tabs at all. These libraries can be somewhat cumbersome for users on slower connections to download, and it&#8217;s definitely the major disadvantage of using a library like jQuery to add this sort of functionality to your site. The best things we can do in this case is try to minimize the effect of serving this JS library to our clients. First of all, I would recommend always using the &#8220;minified&#8221; version of the jQuery script. It&#8217;s much smaller in size than the standard version, which obviously will reduce the amount of time needed to load your site when users first visit it. The only difference between the minified and the standard library is that the good folks at jQuery have removed all sorts of characters in the document, which makes it less readable, but makes the file size much smaller. If you want to delve into the depths of the jQuery library, you can download the standard version and take a gander offline, but don&#8217;t force your users to download the full version if you don&#8217;t have to.</p>
<p>Additionally, Google (<a href="http://code.google.com/apis/ajaxlibs/documentation/#jquery">here</a>) and Microsoft (<a href="http://www.asp.net/ajax/CDN/">here</a>) have both set up distribution networks to serve these libraries to your users. Don&#8217;t waste bandwidth and your clients&#8217; time by forcing users to download these libraries from your servers! Chances are, Google/Microsoft have the resources to serve these files to you users faster and more reliably than you can, so please utilize these free services. Additionally, users have a much greater chance of already having a cached version of these files when you used the shared location. Sweet!</p>
<p>Add the library references to your <code>&lt;head/&gt;</code> to get started.</p>
<pre>&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;http://jqueryui.com/latest/ui/ui.tabs.js&quot;&gt;&lt;/script&gt;</pre>
<h2>The Tabs Markup</h2>
<p>What&#8217;s so wonderfully beautiful about jQuery tabs is the simplicity of the HTML. Even more, users who aren&#8217;t using JavaScript will visit your site and see a perfectly formatted and functioning page. Use this as a template for your tabs HTML:</p>
<pre>&lt;div class=&quot;ui-tabs&quot;&gt;
	&lt;ul class=&quot;ui-tabs-nav&quot;&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-1&quot;&gt;Tab One&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-2&quot;&gt;Tab Two&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;#tabs-3&quot;&gt;Tab Three&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;div id=&quot;tabs-1&quot; class=&quot;ui-tabs-panel&quot;&gt;
		&lt;p&gt;Content one.&lt;/p&gt;
	&lt;/div&gt;
	&lt;div id=&quot;tabs-2&quot; class=&quot;ui-tabs-panel&quot;&gt;
		&lt;p&gt;Content two.&lt;/p&gt;
	&lt;/div&gt;
	&lt;div id=&quot;tabs-3&quot; class=&quot;ui-tabs-panel&quot;&gt;
		&lt;p&gt;Content three.&lt;/p&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<h2>Add Some Style</h2>
<p>This is where my template really starts to differ from jQuery&#8217;s version. The CSS jQuery would have you use is not simple enough for me, so I created my own version of the CSS that will give you a very basic frame onto which you can apply your own design. Here&#8217;s what I like to start with:</p>
<pre>.ui-tabs {
	zoom: 1;
}
.ui-tabs .ui-tabs-nav {
	list-style: none;
	position: relative;
	padding: 0;
	margin: 0;
}
.ui-tabs .ui-tabs-nav li {
	position: relative;
	float: left;
	margin: 0 3px -2px 0;
	padding: 0;
}
.ui-tabs .ui-tabs-nav li a {
	display: block;
	padding: 10px 20px;
	background: #f0f0f0;
	border: 2px #ccc solid;
	border-bottom-color: #ccc;
	outline: none;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a {
	padding: 10px 20px 12px 20px;
	background: #fff;
	border-bottom-style: none;
}
.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,
.ui-tabs .ui-tabs-nav li.ui-state-disabled a,
.ui-tabs .ui-tabs-nav li.ui-state-processing a {
	cursor: default;
}
.ui-tabs .ui-tabs-nav li a,
.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a {
	cursor: pointer;
}
.ui-tabs .ui-tabs-panel {
	display: block;
	clear: both;
	border: 2px #ccc solid;
	padding: 10px;
}
.ui-tabs .ui-tabs-hide {
	display: none;
}</pre>
<h2>Now Make it Do Something</h2>
<p>Now that you have your tabs there, you&#8217;ll have to initialize them with a simple jQuery statement in order for them to work. Just add this line of JavaScript anywhere on your page.</p>
<pre>&lt;script type=&quot;text/javascript&quot;&gt;
	$(document).ready(function(){
		$(&quot;.ui-tabs&quot;).tabs();
	});
&lt;/script&gt;</pre>
<h2>The Result</h2>
<p>Once you&#8217;ve added each of these elements to your page, you should get a very simple tab structure that awaits your styling genius. Just modify the CSS to apply your own design!</p>
<div class="ui-tabs">
<ul class="ui-tabs-nav">
<li><a href="#tabs-1">Tab One</a></li>
<li><a href="#tabs-2">Tab Two</a></li>
<li><a href="#tabs-3">Tab Three</a></li>
</ul>
<div id="tabs-1" class="ui-tabs-panel">
<p>Content one.</p>
</div>
<div id="tabs-2" class="ui-tabs-panel">
<p>Content two.</p>
</div>
<div id="tabs-3" class="ui-tabs-panel">
<p>Content three.</p>
</div>
</div>
<p><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script><script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.tabs.js"></script><script type="text/javascript">$(document).ready(function(){$(".ui-tabs").tabs();});</script><br />
<style type="text/css">#content .ui-tabs { zoom: 1; }
#content .ui-tabs .ui-tabs-nav { list-style: none; position: relative; padding: 0; margin: 0; }
#content .ui-tabs .ui-tabs-nav li { list-style: none; position: relative; float: left; margin: 0 3px -2px 0; padding: 0; }
#content .ui-tabs .ui-tabs-nav li a { display: block; padding: 10px 20px; background: #f0f0f0; border: 2px #ccc solid; border-bottom-color: #ccc; outline: none; }
#content .ui-tabs .ui-tabs-nav li.ui-tabs-selected a { padding: 10px 20px 12px 20px; background: #fff; border-bottom-style: none; }
#content .ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: default; }
#content .ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; }
#content .ui-tabs .ui-tabs-panel { display: block; clear: both; border: 2px #ccc solid; padding: 10px; }
#content .ui-tabs .ui-tabs-hide { display: none; }</style>
<p>Now you&#8217;ve got it. Good luck, and happy styling.</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/web-controls/simple-jquery-tabs-template/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Pure CSS Image Hover</title>
		<link>http://kyleschaeffer.com/best-practices/pure-css-image-hover/</link>
		<comments>http://kyleschaeffer.com/best-practices/pure-css-image-hover/#comments</comments>
		<pubDate>Mon, 05 Jan 2009 14:14:17 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[Images]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=142</guid>
		<description><![CDATA[Many site designs will feature varying types of image &#8220;hover&#8221; states, where an image or background image changes when you move your mouse cursor into that area of the page. Traditionally, this change in image is handled via JavaScript. It&#8217;s &#8230; <a href="http://kyleschaeffer.com/best-practices/pure-css-image-hover/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Many site designs will feature varying types of image &#8220;hover&#8221; states, where an image or background image changes when you move your mouse cursor into that area of the page. Traditionally, this change in image is handled via JavaScript. It&#8217;s fairly easy to write a small script that swaps out images on mouseover, but there are a number of disadvantages to this approach that have pushed many web developers toward using a CSS-only method of achieving this exact same effect. This tutorial describes exactly how to implement a pure CSS image hover effect.<span id="more-142"></span></p>
<h2>The Image</h2>
<p>The biggest difference between a traditional JavaScript image hover and a pure CSS image hover is the image, itself. When using CSS to achieve this effect, the static image and the hover image are actually contained within the same image file. Basically, we&#8217;re displaying the image and cropping it so that only one image state is displayed at one time. In order to do this, we&#8217;ll omit the <code>&lt;img&gt;</code> tag and display the image as a the background-image of an <code>&lt;a/&gt;</code> (anchor) tag instead.</p>
<p>Let&#8217;s look at an image that could be used as a CSS hover image.</p>
<p style="text-align: center;"><img title="Both image states are contained within the same image." src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2009/01/buttonleafhover.png" alt="Hover image" width="100" height="200" /></p>
<h2>Simplistic Markup</h2>
<p>As you can see, both static and hover images are contained within the same file.  In order to display only half of the image at one time, we&#8217;ll apply it as a background color to an HTML block element.  Here is the HTML for this example:</p>
<pre>&lt;a class=&quot;myButtonLink&quot; href=&quot;#LinkURL&quot;&gt;Leaf&lt;/a&gt;</pre>
<h2>The CSS</h2>
<p>As you can see, the HTML is extremely simple.  We&#8217;re doing everything in CSS, so this is where the real magic happens:</p>
<pre>.myButtonLink {
	display: block;
	width: 100px;
	height: 100px;
	background: url('/path/to/myImage.png') bottom;
	text-indent: -99999px;
}
.myButtonLink:hover {
	background-position: 0 0;
}</pre>
<p>We&#8217;re using the CSS psuedo-element <code>hover</code> to apply the mouseover image effect.  When your mouse pointer moves over the &#8220;myButtonLink&#8221; element, our CSS slides the background image (using the <code>background-position</code> property) appropriately, giving us our mouseover image.  This is simple, fast, and efficient!  You&#8217;ll use less files and space on your server, clients will have to download less data, and older computers will render your content much faster.</p>
<h2>The Result</h2>
<p>Move your mouse over the image to see the hover in action.</p>
<style type="text/css">.myButtonLink { display: block; width: 100px; height: 100px; margin: 1em auto; background: url('http://kyleschaeffer.com/wordpress/wp-content/uploads/2009/01/buttonleafhover.png') bottom; text-indent: -99999px; }
.myButtonLink:hover { background-position: 0 0; background-color: transparent; border-style: none; }</style>
<p><a class="myButtonLink" href="javascript:alert('Accessible design is good design.\n~Steve Ballmer');">Leaf</a></p>
<p>And there you have it, a pure CSS approach to image hovers. You can apply this method to links, <code>&lt;div/&gt;</code> tags, and just about anything else you can imagine in your site&#8217;s design. Happy styling!</p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/best-practices/pure-css-image-hover/feed/</wfw:commentRss>
		<slash:comments>176</slash:comments>
		</item>
		<item>
		<title>Create a DHTML Tab Strip</title>
		<link>http://kyleschaeffer.com/tutorials/create-a-dhtml-tab-strip/</link>
		<comments>http://kyleschaeffer.com/tutorials/create-a-dhtml-tab-strip/#comments</comments>
		<pubDate>Tue, 18 Nov 2008 18:18:23 +0000</pubDate>
		<dc:creator>Kyle</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web Controls]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tabs]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://www.kyleschaeffer.com/?p=107</guid>
		<description><![CDATA[Tab strips are commonplace throughout the web, and they&#8217;re utilized in a wide variety of ways, such as in site navigation or form wizards. Organizing links in a tabbed format can add quite a bit of style and functionality to &#8230; <a href="http://kyleschaeffer.com/tutorials/create-a-dhtml-tab-strip/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Tab strips are commonplace throughout the web, and they&#8217;re utilized in a wide variety of ways, such as in site navigation or form wizards.  Organizing links in a tabbed format can add quite a bit of style and functionality to your site, as many visitors are already familiar and comfortable with using tabs on other websites and even on other platforms such as their operating system.  This tutorial shows you how to create a simple DHTML tab strip using HTML, CSS, and a small bit of JavaScript.<span id="more-107"></span></p>
<p>When I use the term &#8220;DHTML,&#8221; I am referring to &#8220;Dynamic HTML.&#8221;  This is an endearing term that many web designers use to describe the fusion of HTML with other web technologies, such as JavaScript and CSS.  By using various technologies in tandem, we can create dynamic controls that allow website visitors to interact with content directly on the page without the need to refresh the site with every subsequent click.</p>
<h2>The HTML</h2>
<p>As you will soon see, the tab strip is a prime example of a DHTML control.  Before we delve into every aspect of the tab strip, let&#8217;s first start with the HTML:</p>
<pre>&lt;div class=&quot;tabStrip&quot;&gt;
	&lt;ul&gt;
		&lt;li&gt;&lt;a href=&quot;javascript:openTab(1);&quot; class=&quot;tabLinkActive&quot; id=&quot;tabLink1&quot;&gt;TabOne&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;javascript:openTab(2);&quot; class=&quot;tabLink&quot; id=&quot;tabLink2&quot;&gt;TabTwo&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;javascript:openTab(3);&quot; class=&quot;tabLink&quot; id=&quot;tabLink3&quot;&gt;TabThree&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;tabContentActive&quot; id=&quot;tabContent1&quot;&gt;
	This is sample tab content (1).
&lt;/div&gt;
&lt;div class=&quot;tabContent&quot; id=&quot;tabContent2&quot;&gt;
	This is sample tab content (2).
&lt;/div&gt;
&lt;div class=&quot;tabContent&quot; id=&quot;tabContent3&quot;&gt;
	This is sample tab content (3).
&lt;/div&gt;</pre>
<p>The HTML is relatively simple. We are using an unordered list (<code>&lt;ul/&gt;</code>) for our tabs, and we are using <code>&lt;div/&gt;</code> tags for our tab content. As you can see, I am giving a unique <code>id</code> attribute to each tab link and to each tab content <code>&lt;div/&gt;</code>.  This is important, as we&#8217;ll need unique <code>id</code>&#8216;s in order to access these elements with JavaScript.</p>
<h2>The JavaScript</h2>
<p>We are using only one small JavaScript function for the tab control.  Here is the code:</p>
<pre>&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&gt;
	var activeTab = 1;
	function openTab(tabId) {
		// reset old tab and content
		document.getElementById(&quot;tabLink&quot;+activeTab).className = &quot;tabLink&quot;;
		document.getElementById(&quot;tabContent&quot;+activeTab).className = &quot;tabContent&quot;;
		// set new tab and content
		document.getElementById(&quot;tabLink&quot;+tabId).className = &quot;tabLinkActive&quot;;
		document.getElementById(&quot;tabContent&quot;+tabId).className = &quot;tabContentActive&quot;;
		activeTab = tabId;
	}
&lt;/script&gt;</pre>
<h2>The CSS:</h2>
<p>This CSS is a very basic example of what you can do to style your tabs. You can add colors, gradients, and background images to give the control even more design flare.</p>
<pre>.tabStrip ul {
	margin: 0;
	padding: 0;
	list-style-type: none;
}
.tabStrip li {
	margin: 0 2px 0 0;
	list-style-type: none;
	float: left;
}
.tabLink {
	display: block;
	text-decoration: none;
	padding: 5px;
	background: #e8e8e8;
	border: #dadada solid;
	border-width: 1px 1px 0 1px;
	color: #8a8a8a;
}
.tabLinkActive {
	display: block;
	text-decoration: none;
	padding: 5px;
	background: #e0e0e0;
	border: #c0c0c0 solid;
	border-width: 1px 1px 0 1px;
	color: #0066ff;
}
.tabContent {
	display: none;
}
.tabContentActive {
	display: block;
	clear: both;
	background: #f0f0f0;
	border: 1px #dedede solid;
	padding: 10px;
}</pre>
<h2>The Result:</h2>
<p>In true DHTML fashion, we have combined HTML, JavaScript, and CSS to create a fully dynamic user control that can appear anywhere on the web. I have taken the fundamentals learned in this tutorial and have created a more visually appealing example of this code.  Click on the image below to see the demo.</p>
<p><a href="http://www.kyleschaeffer.com/tabstrip/"><img src="http://kyleschaeffer.com/wordpress/wp-content/uploads/2008/11/tabs.jpg" alt="Tab Strip Demo" /></a></p>
<p>Note that the demo also utilizes Karate Corners to create rounded edges on the tabs.  <a href="http://www.kyleschaeffer.com/tutorials/karate-corners-easy-rounded-corners-xhtml-no-script/">Learn more about Karate corners here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kyleschaeffer.com/tutorials/create-a-dhtml-tab-strip/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

