Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class='tabs'>
  <!-- Flattern structure for adjacent sibling combinator -->
  
  <!-- Tab 1 & Content -->
  <input type="radio" name="tab" id="tab1" checked>
  <label for="tab1">Tab 1</label>
  <section>
    <h2>Content of Tab 1</h2>
    <p>Hello World</p>
  </section>
  
  <!-- Tab 2 & Content -->
  <input type="radio" name="tab" id="tab2">
  <label for="tab2">Tab 2</label>
  <section>
    <h2>Content of Tab 2</h2>
    <p>Hello World</p>
  </section>
  
  <!-- Tab 3 & Content -->
  <input type="radio" name="tab" id="tab3">
  <label for="tab3">Tab 3</label>
  <section>
    <h2>Content of Tab 3</h2>
    <p>Hello World</p>
  </section>
  
  <!-- Tab 4 & Content -->
  <input type="radio" name="tab" id="tab4">
  <label for="tab4">Tab 4</label>
  <section>
    <h2>Content of Tab 4</h2>
    <p>Hello World</p>
  </section>
  
</div>
              
            
!

CSS

              
                /* For debug only */
// * {
//   border: 1px solid black !important;  
//   padding: 1em;
// }


.tabs {
  /* Step 1: Enable Flex on the container */
  display: flex;
  
  /* Step 2: Enable flex-wrap to put content section below tab label */
  flex-wrap: wrap;
}
.tabs > section {  
  /* Step 3: Move content <section> to the end, after the tab labels */
  order: 999;
  
  /* Step 4: Make sure the content <section> is 100% width */
  width: 100%;
  
  /* Step 5: Hide all content <section> by default */
  display: none;
}
.tabs > input {
  /* display: none; Don’t use display:none. Bad for accessibility */
  
  /* Step 6: Hide the radio inputs */
  opacity: 0;
  
  /* Step 7: Make sure the radio inputs don’t take up space in layout */
  position: absolute;
}
/* Step 8: Select the label right next to the selected input */
.tabs > input[type=radio]:checked + label {
  /* Step 9: Highlight the selected label */
  background: yellow;
}
/* Step 10: Select the section right next to the label which is next to the selected input */
.tabs > input[type=radio]:checked + label + section {
  /* Step 11: Unset the 'display:none' we did in step 5 */
  display: unset;
}

/* Done. Make sure to disable the debug code at the beginning of CSS. And now it is time to make the tabs look good */

/* Make the tabs look good */
/* Final Step: Make the tabs pretty with padding and colors */

.tabs > label {
  padding: .5em 1em;
  background: #b4d5e4;
  border-right: 1px solid #798f99;
}
.tabs > label:last-of-type {
  border-right: none;
}
.tabs > input[type=radio]:checked + label {
  background: #798f99;
} 

.tabs section {
  border: 1px #798f99 solid;
  border-top: 5px #798f99 solid;
  padding: 1em;
}

.tabs {
  margin: 2em;
}


              
            
!

JS

              
                
              
            
!
999px

Console