Edit on
<div class="tabs">
  
  <div class="tab">
    <input class="tab-radio" type="radio" id="tab-1" name="tab-group-1" checked>
    <label class="tab-label" for="tab-1">Huh? Tabs again?</label>
    
    <div class="tab-panel">
      <div class="tab-content">
        <h3>Why would this be cool?</h3>
        <p>First look at the HTML structure: all elements related to one tab are within one block. Now think about that for a while. This must be done by Chris Coyier's <a href="http://css-tricks.com/functional-css-tabs-revisited/">Functional CSS Tabs Revisited</a> already, right?</p>
        <p>Maybe. But then you may notice another thing: Chris' example uses absolute positioning for the content. This means the tabs must be of fixed height. Yet these tabs here certainly aren't!</p>
      </div>
    </div> 
  </div>
  
  <div class="tab">
    <input class="tab-radio" type="radio" id="tab-2" name="tab-group-1">
    <label class="tab-label" for="tab-2">Variable height content</label>
    
    <div class="tab-panel">
      <div class="tab-content">
        <h3>What is this devilry?</h3>
        <p>First of all we are working with inline content here and being smart about it. We eliminate white space using the dirty but sufficient zero font-size.</p>
        <p>There is one additional element in comparison to what Chris had: <code>.tab-panel</code> element, which works as a container for the <code>.tab-content</code> element. The panel is inline-block by default, which means it can take styles like overflow, position, and width and height. We set these to zero size, use <code>overflow: hidden;</code> and <code>position: relative;</code> so that <code>.tab-content</code> disappears. For the active tab we do only one style change and it happens to the <code>.tab-panel</code> element: we make it inline! Thus it no longer follows the other rules that bind inline-block. As a result it's child element will start following the flow of the next container element up in the tree.</p>
        <p>As for the <code>.tab-content</code> element it is floated and has a width of 100%. The neat thing about this combination is that it forces the element to go below the row where you can see the tab buttons.</p>
      </div>
    </div>
  </div>
  
  <div class="tab">
    <input class="tab-radio" type="radio" id="tab-3" name="tab-group-1">
    <label class="tab-label" for="tab-3">Browser support</label>
    <div class="tab-panel">
      <div class="tab-content">
        <h3>The support must be poor!</h3>
        <p>The CSS only part of this solution works in Internet Explorer 9+. All the other browsers are supported from so far back that it is enough to tell this works on Firefox, Chrome, Safari and Opera.</p>
        <p>The JavaScript is quite simple and it is for IE8 and below. It does no harm to other browsers, but you probably want to hide it behind IE conditional comments: <code>&lt;!--[if lte IE 8]&gt; &hellip; &lt;![endif]--&gt;</code></p>
      </div>
    </div>
  </div>
  
  <div class="tab">
    <input class="tab-radio" type="radio" id="tab-4" name="tab-group-1">
    <label class="tab-label" for="tab-4">Internet Explorer 8<br /><small>And IE7, why not IE6 too</small></label>
    
    <div class="tab-panel">
      <div class="tab-content">
        <h3>Supporting the old</h3>
        <p>Internet Explorer 8 and below do not support the required <code>:checked</code> selector. This is why there is some JavaScript. It doesn't do a whole lot really: the active <code>.tab</code> element gets class <code>checked</code> and then we use that in CSS.</p>
        <p>Due to redrawing issues in IE8 we avoid using selectors like + and ~ with it. And this is also the reason we set class to the <code>.tab</code> element and not the radio button.</p>
        <p>The most interesting thing with styling in IE8 and below is to keep the input element on the page: if the element is hidden using <code>display: none;</code> then we never get the click events. To achieve a hidden input we position it absolutely and use IE proprietary Alpha filter to make it invisible. Then finally <code>z-index</code> throws it behind so it can't be clicked. To target the element properly an additional class of <code>.tab-radio</code> is added to the radio button. It is for IE8- only.</p>
        <p>All IE8- styles are within one media query so it's easy to remove it. It is also easy to remove IE7 and IE6 only styles by following the comments.</p>
      </div>
    </div>
  </div>
  
</div>

<h3>Summary</h3>
<p>This method gives you dynamic size for both the tabs and the content area. You can make varying height tabs as you can see and it just works. The tabs can be variable width. The content can be variable height (but not variable width, although that wouldn't make sense anyway). With very little JavaScript and some more CSS we get support for IE6+.</p>

<h3>The HTML Structure</h3>
<pre><code>&lt;div class=&quot;tabs&quot;&gt;
  
  &lt;div class=&quot;tab&quot;&gt;
    &lt;input <span class="for ie8-and-below">class=&quot;tab-radio&quot;</span> type=&quot;radio&quot; id=&quot;tab-X&quot; name=&quot;tab-group-Y&quot; <span class="for default-tab">checked</span>&gt;
    &lt;label class=&quot;tab-label&quot; for=&quot;tab-X&quot;&gt;TAB TITLE&lt;/label&gt;
    
    &lt;div class=&quot;tab-panel&quot;&gt;
      &lt;div class=&quot;tab-content&quot;&gt;
        TAB CONTENT GOES HERE
      &lt;/div&gt;
    &lt;/div&gt; 
  &lt;/div&gt;
  
&lt;/div&gt;</code></pre>
.tabs {
  font-size: 0;
  margin: 25px 0;
}

.tabs:after {
  clear: both;
  content: '';
  display: table;
}

.tabs .tab {
  display: inline;
}

.tabs .tab-label {
  background: #eee; 
  border: 1px solid #ccc; 
  display: inline-block;
  font-size: 16px;
  font-size: 1rem;
  left: 1px;
  margin-left: -1px;
  padding: 10px; 
  position: relative;
  vertical-align: bottom;
}

.tabs .tab > [type="radio"] {
  clip: rect(0 0 0 0);
  height: 1px;
  opacity: 0;
  position: fixed;
  width: 1px;
  z-index: -1;
}

.tabs .tab-panel {
  display: inline;
  display: inline-block;
  overflow: hidden;
  position: relative;
  height: 0;
  width: 0;
}

.tabs .tab-content {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  display: block;
  background: white;
  padding: 0 20px;
  border: 1px solid #ccc;
  float: left;
  font-size: 16px;
  font-size: 1rem;
  margin-top: -1px;
  width: 100%;
}

.tabs .tab [type="radio"]:checked + .tab-label {
  background: white;
  border-bottom-width: 0;
  padding-bottom: 11px;
  z-index: 1;
}

.tabs .tab [type="radio"]:checked ~ .tab-panel {
  display: inline;
}


/*

=======================================
INTERNET EXPLORER 8 and below 
=======================================

*/
@media \0screen\,screen\9 {
  /* IE7 and IE6 */
  .tabs {
    zoom: 1;
  }
  
  /* IE8 and below */
  .tabs .tab .tab-radio {
    filter: Alpha(opacity=0);
    position: absolute;
    z-index: -1;
  }
  
  /* IE7 and IE6 */
  .tabs .tab .tab-panel, {
    display: none;
    height: auto;
    overflow: visible;
    position: static;
    width: auto;
  }
  
  /* IE7 and IE6 */
  .tabs .tab-content, {
    float: none;
    padding-bottom: 1px;
    padding-top: 1px;
    width: auto;
  }
  
  /* IE8 and below */
  .tabs .checked label {
    background: white;
    border-bottom-width: 0;
    padding-bottom: 11px;
    z-index: 1;
  }
  
  /* IE8 */
  .tabs .checked .tab-panel {
    display: inline;
  }
  /* IE7 and IE6 */
  .tabs .checked .tab-panel, {
    display: inline;
    float: left;
    width: 100%;
  }
}






/*

=======================================
UNIMPORTANT STYLES BEGIN HERE
=======================================

*/
html {
  background: #333;
  color: #DDD;
  padding: 1em;
}

a:link,a:visited,a:hover,a:focus,a:active {
  color: #58C;
}

label {
  cursor: pointer;
}

.tabs {
  color: #222;
}

.tabs a:link,.tabs a:visited,.tabs a:hover,.tabs a:focus,.tabs a:active {
  color: #36A;
}

body > h3 {
  font-variant: small-caps;
  letter-spacing: .0625em;
}

p {
  line-height: 1.5;
  max-width: 50em;
}

code,pre {
  font-family: 'Lucida Console', monospace;
}

pre {
  background: #191919;
  color: #8DA;
  overflow-x: auto;
  padding: 1em;
}

p > code {
  background: #DED;
  margin: -2px;
  padding: 2px;
}

.for {
  display: inline-block;
  position: relative;  
}

.for:after {
  background: #DDD;
  bottom: 150%;
  color: #222;
  font-family: sans-serif;
  font-size: 12px;
  opacity: 0;
  padding: .5em;
  pointer-events: none;
  position: absolute;
  right: 0;
  -webkit-transition: opacity .2s ease-in-out;
  transition: opacity .2s ease-in-out;
  white-space: nowrap;
}

.for:hover:after {
  opacity: 1;
}

.for.default-tab {
  color: #8AD;
}

.for.ie8-and-below {
  color: #DA8;
}

.for.default-tab:after {
  content: 'For default tab';  
}

.for.ie8-and-below:after {
  content: 'For IE8 and below';  
}

/* and just for fun... */
@media only screen and (max-width: 43em) {
  .tabs .tab > label {
    background: #BBB;
    border-color: #999;
    
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
  }
  .tabs .tab [type="radio"]:checked + .tab-label {
    background: #222;
    border-color: #444;
    color: #DDD;
  }
}
// in HTML <head>:
// <!--[if lt IE 9]><script>window.ltIE9=true</script><![endif]-->
if(window.ltIE9) {
  (function($) {
    $('.tabs input[type="radio"]:checked')
    .closest('.tab')
    .addClass('checked');
    $('html').on('click', '.tabs input', function() {
      $('input[name="' + this.name + '"]')
      .closest('.tab')
      .removeClass('checked');
      $(this)
      .closest('.tab')
      .addClass('checked');
    });
  })(window.jQuery);
}
Rerun