:target usually the preferred way to make tabs.
You can also be smart with input:radio or input:checkbox elements.
http://jsfiddle.net/nzYnc/
HTML:
<label for="one">One</label> <label for="two">Two</label> <label for="three">Three</label> <input type="radio" id="one" name="tab" checked="checked" /> <div> First content </div> <input type="radio" id="two" name="tab" /> <div> Second content </div> <input type="radio" id="three" name="tab" /> <div> Third content </div>
CSS
input { position: absolute; right: 100%; } input:checked + div { display: block; } div { display: none; }
Using the next-sibling ( + ) and :checked selectors in clever ways allows you to do pure CSS accordions, toggleable lists, or tabs like this.
source share