The html5rockstars.com demo archive is here: https://web.archive.org/web/20121118201357/http://htmlrockstars.com/blog/using-css-to-create-a-tabbed. - cross-zone-no-JS-required /
The same method is described, perhaps better, here: http://www.sitepoint.com/css3-tabs-using-target-selector/
It all comes down to using the CSS3 :target selector :target to show which tab is currently selected. This will only work if the page has only one set of tabs, but has the advantage of fully supporting the back button of the browser. For instance:
<ul id="menu"> <li><a href="#tab1">First tab</a></li> <li><a href="#tab2">Second tab</a></li> <li><a href="#tab3">Third tab</a></li> </ul> <div id="tab1" class="tab-content">Content of first tab</div> <div id="tab2" class="tab-content">Content of second tab</div> <div id="tab3" class="tab-content">Content of third tab</div>
And then in your stylesheet:
.tab-content { display: none; } .tab-content:target { display: block; }
Unfortunately, this is not ideal, since the contents of the tab will not be displayed until one of the links is clicked (unless you are page.html#tab1 on page.html#tab1 ). The second link above offers something like the following as a solution to this problem:
.tab-content { z-index: 0; background-color: white; position: absolute; top: 100px; width: 100%; height: 300px; } .tab-content:first-child { z-index: 1; } .tab-content:target { z-index: 2; }
This is somewhat hacky, and also requires absolute positioning.
Alternatively, if you don't mind your default tab being the last in html (you can arrange the links as you like, of course), you can do this:
<ul id="menu"> <li><a href="#tab1">First tab</a></li> <li><a href="#tab2">Second tab</a></li> <li><a href="#tab3">Third tab</a></li> </ul> <div class="tab-folder"> <div id="tab2" class="tab-content">Content of second tab</div> <div id="tab3" class="tab-content">Content of third tab</div> <div id="tab1" class="tab-content">Content of first tab</div> </div>
CSS:
.tab-folder > .tab-content:target ~ .tab-content:last-child, .tab-folder > .tab-content { display: none; } .tab-folder > :last-child, .tab-folder > .tab-content:target { display: block; }
Perhaps this is the cleanest solution that I would choose among others, unless I suspected that many people would visit my page with CSS disabled.