<?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>Web Prose</title>
	<atom:link href="http://webprose.cc/feed/" rel="self" type="application/rss+xml" />
	<link>http://webprose.cc</link>
	<description>Web Prose - blogging, javascript, html, css trick and tips</description>
	<lastBuildDate>Tue, 16 Mar 2010 19:03:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Valid and semantic way to make HTML Tabs with DL(definition list) and jQuery</title>
		<link>http://webprose.cc/htmlcss-tips/3/</link>
		<comments>http://webprose.cc/htmlcss-tips/3/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 21:33:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HTML/CSS tips]]></category>

		<guid isPermaLink="false">http://webprose.cc/htmlcss-tips/3/</guid>
		<description><![CDATA[Few month ago I needed to make tabs on the webpage. I googled and found standard solutions that I didn’t like. The problem was solved using two independent blocks: the first one contains headers, the second one – texts. I didn’t like that structure, mainly because there was no semantic link between the header and [...]]]></description>
			<content:encoded><![CDATA[<p>Few month ago I needed to make tabs on the webpage. I googled and found standard solutions that I didn’t like. The problem was solved using two independent blocks: the first one contains headers, the second one – texts.</p>
<p>I didn’t like that structure, mainly because there was no semantic link between the header and the content. I googled more and more)) and found a GREAT solution using &lt;DL&gt; (definition list). The author of these &lt;DL&gt; html tabs is <a href="http://chikuyonok.ru/">Sergey Chikuyonok</a> &#8211; one of best web designers in Russia and in the World. I found many great HTML/CSS trick and solutions that I use in my works.
</p>
<p>So here is <a href="http://webprose.cc/data/dl-tabs/dl-tabs.html">HTML tabs with &lt;dl&gt;</a></p>
<p>And here is consideration of this solution:</p>
<p>Let&#8217;s make an attribute <em>float:left</em> for all elements:</p>
<p class="txt-center"><img src="http://webprose.cc/data/dl-tabs/dl-tabs-1.jpg" alt="DL Tabs - Step 1" /></p>
<p>This will happen if we set the <em>float:right</em> attribute for one of the elements:</p>
<p class="txt-center"><img src="http://webprose.cc/data/dl-tabs/dl-tabs-2.jpg" alt="DL Tabs - Step 2" /></p>
<p><img src="http://www.splashnology.com/uploads/images/2/1/0/8/75/b70f322379.png"/><br/></p>
<p>As you can see, the elements following are placed on the same line. But we need the tab content to be stretched to the whole width, so we set <em>width:100%</em> for &lt;DD&gt;:</p>
<p class="txt-center"><img src="http://webprose.cc/data/dl-tabs/dl-tabs-3.jpg" alt="DL Tabs - Step 3" /></p>
<p>The &lt;DD&gt; element has broken the document flow. So what we have: if an element is snapped to the container&#8217;s right edge, then changing the container&#8217;s width will shift the element&#8217;s left edge (i.e., increases from right to left). That&#8217;s way we need to suppress the influence of the element&#8217;s left edge, and that can be done by setting <em>margin-left:-100%</em>:</p>
<p class="txt-center"><img src="http://webprose.cc/data/dl-tabs/dl-tabs-4.jpg" alt="DL Tabs - Step 4" /></p>
<p>Now we just need to move the &lt;DD&gt; down. We&#8217;ll do this using <em>margin-top</em> attribute:</p>
<p class="txt-center"><img src="http://webprose.cc/data/dl-tabs/dl-tabs-ready.jpg" alt="DL Tabs - Ready" /></p>
<p>That&#8217;s all! To hide all elements by default, we set the <em>display:none</em> attribute for them, while setting <em>display: block</em> for the selected element.</p>
<p>For the tab toggling we&#8217;ll use simple jQuery script:</p>
<pre style="font-size:12px"><code>
$(function(){
	$('dl.tabs dt').click(function(){
		$(this).siblings().removeClass('selected').end()
        .next('dd').andSelf().addClass('selected');
	});
});
</code></pre>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://webprose.cc/htmlcss-tips/3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
