CSS only tabs using input:checked - HTML CSS CSS Form

HTML CSS examples for CSS Form:input

Description

CSS only tabs using input:checked

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">
input {<!--from  ww  w.  j  a  v  a 2s  .c  om-->
   display:none;
}

nav {
   overflow:hidden
}

label {
   float:left;
   display:inline-block;
   padding:6px 11px;
}

label a {
   color:Chartreuse;
   text-decoration:underline;
   cursor:pointer;
}

.tab {
   display:none;
   border:2px solid yellow;
   padding:11px;
}

a[name="tab1"] + .tab {
   display:block
}

:target + .tab {
   display:block
}

:target~a[name="tab1"] + .tab {
   display:none
}
</style> 
 </head> 
 <body> 
  <section class="tab-area tabs-checked"> 
   <nav> 
    <input checked type="radio" name="tab" id="tab-A"> 
    <input type="radio" name="tab" id="tab-B"> 
    <input type="radio" name="tab" id="tab-C"> 
    <label class="tab-link" for="tab-A"> <a href="#tab1">Lorem</a> </label> 
    <label class="tab-link" for="tab-B"> <a href="#tab2">Lorem</a> </label> 
    <label class="tab-link" for="tab-C"> <a href="#tab3">Lorem</a> </label> 
   </nav> 
   <a name="tab3"></a> 
   <article class="tab"> 
    <h3>Lorem</h3> 
   </article> 
   <a name="tab2"></a> 
   <article class="tab"> 
    <h3>Lorem</h3> 
   </article> 
   <a name="tab1"></a> 
   <article class="tab"> 
    <h3>Lorem </h3> 
   </article> 
  </section>  
 </body>
</html>

Related Tutorials