Create a pure CSS content TABS

HTML

<ul class="tabs">
<li>
          <input type="radio" checked name="tabs" id="tab1">
          <label for="tab1">tab 1</label>
<div id="tab-content1" class="tab-content animated fadeIn">
    ...
          </div>
        </li>
<li>
          <input type="radio" name="tabs" id="tab2">
          <label for="tab2">tab 2</label>
<div id="tab-content2" class="tab-content animated fadeIn">
            ...
          </div>
        </li>
<li>
          <input type="radio" name="tabs" id="tab3">
          <label for="tab3">tab 3</label>
<div id="tab-content3" class="tab-content animated fadeIn">
            ...
          </div>
        </li>
</ul>

CSS

body, html {
          height: 100%;
          margin: 0;
          -webkit-font-smoothing: antialiased;
          font-weight: 100;
          background: #aadfeb;
          text-align: center;
          font-family: helvetica;
      }
       
      .tabs input[type=radio] {
          position: absolute;
          top: -9999px;
          left: -9999px;
      }
      .tabs {
        width: 650px;
        float: none;
        list-style: none;
        position: relative;
        padding: 0;
        margin: 75px auto;
      }
      .tabs li{
        float: left;
      }
      .tabs label {
          display: block;
          padding: 10px 20px;
          border-radius: 2px 2px 0 0;
          color: #08C;
          font-size: 24px;
          font-weight: normal;
          font-family: 'Lily Script One', helveti;
          background: rgba(255,255,255,0.2);
          cursor: pointer;
          position: relative;
          top: 3px;
          -webkit-transition: all 0.2s ease-in-out;
          -moz-transition: all 0.2s ease-in-out;
          -o-transition: all 0.2s ease-in-out;
          transition: all 0.2s ease-in-out;
      }
      .tabs label:hover {
        background: rgba(255,255,255,0.5);
        top: 0;
      }
       
      [id^=tab]:checked + label {
        background: #08C;
        color: white;
        top: 0;
      }
       
      [id^=tab]:checked ~ [id^=tab-content] {
          display: block;
      }
      .tab-content{
        z-index: 2;
        display: none;
        text-align: left;
        width: 100%;
        font-size: 20px;
        line-height: 140%;
        padding-top: 10px;
        background: #08C;
        padding: 15px;
        color: white;
        position: absolute;
        top: 53px;
        left: 0;
        box-sizing: border-box;
        -webkit-animation-duration: 0.5s;
        -o-animation-duration: 0.5s;
        -moz-animation-duration: 0.5s;
        animation-duration: 0.5s;
      }

First, in order to replicate the function of JavaScript, we need to find a way to allow CSS know the user clicks the button. Using JavaScript, we can simply add click on a class name, but since we do not intend to use JavaScript, we need to break our way through this. What I did is I’m using the rel attribute is linked to a label marked with a hidden radio button. The label will be used as a button, when you click on the tag, which will trigger the link radio button “select” Properties. Now, we can target our style a: Check the selection.

From the HTML tags, you can see, my radio buttons, labels and containers at the same level. There’s a reason. With awesome CSS brothers combinator (~) help, we can have a choice, even without its nested triggers another the same level of choice. This allows us to have a radio button to check display trigger any container so that it uses JavaScript to create a normal copy of the Content tab behavior.