css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <!doctype html>
<html lang="en">

  <title>JS CSS Tabs</title>
  <link rel="stylesheet" href="mytabs.css">


  <section class="tabs-section">
    <div id="horizontal-tabs">
      <ul class="tabs">
        <div class="selector"></div>
        <li class="tab active-item">Meteors</li>
        <li class="tab">Moons</li>
        <li class="tab">Stars </li>
        <li class="tab">Galaxies</li>
      <div class="tab-content">
        <div id="item1" class="tab-item-content  active">
          <p>Here are some of the largest meteors:</p>
            <li>Tunguska </li>
            <li>Crab Pulsar </li>
            <li>Geminga </li>
            <li>Calvera </li>
            <li>Vela X-1 </li>
            <li>Gaspra </li>
            <li>Psyche </li>
        <div id="item2" class="tab-item-content">
          <p>Here are some of the moons we know of:</p>
            <li>Ganymede </li>
            <li>Callisto </li>
            <li>IO </li>
            <li>Oberon </li>
            <li>Ariel </li>
            <li>Umbriel </li>
            <li>Europa </li>
        <div id="item3" class="tab-item-content">
          <p>Here are some of the largest stars we know of:</p>
            <li>UY Scuti </li>
            <li>VV Cephei </li>
            <li>VY Canis Majoris </li>
            <li>KY Cygni </li>
            <li>Betelgeuse </li>
            <li>Eta Carinae </li>
            <li>Antares </li>
            <li>Rigel </li>
            <li>Deneb </li>
        <div id="item4" class="tab-item-content">
          <p>Here are some of the galaxies we know of:</p>
            <li>IC 1101 </li>
            <li>Messier 87 </li>
            <li>Pinwheel </li>
            <li>Sombrero </li>
            <li>Tadpole </li>
            <li>Andromeda </li>
            <li>Black Eye </li>
            <li>Star Bust </li>
  <script src="mytabs.js"></script>


              /* @import allows us import a stylesheet from a url */
@import url('https://fonts.googleapis.com/css?family=Ubuntu');

  margin: 0;
  padding: 0;
  font-family: 'Ubuntu', sans-serif;
  background: #00796B;
  padding-top: 40px;
  max-width: 600px;
  display: block;
  margin: 0 auto;
  /* display  determines the type of box or boxes that are generated for an element. */
  display: inline-flex;
  justify-content: flex-start;
  align-items: center;
  list-style: none;
  background-color: #FF5733;
  color: #fff;
  font-weight: 400;
  border-radius: 3px;
  width: content-box;
  position: relative;

  display: block;
  padding: 11px 20px;
  position: relative;
  /* 'z-index' property specifies the stack level of the box in the current stacking context  */
  z-index: 99999;

  /* cursor allows control over cursor appearance in an element */
  cursor: pointer;

  position: absolute;
  height: 40px;
  transition: all 500ms cubic-bezier(0.080, -0.195, 0.140, 0.970);
  background: #FF9800;

  position: absolute;
  z-index: -1;
  left: calc(50% - 10px);
  bottom: -10px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 10px 10px 0 10px;
  border-color: #FF9800 transparent transparent transparent;
.tab-content .tab-item-content{
  background: #ffffff;
  border-radius: 3px;
  box-sizing: border-box;
  display: none;

.tab-content .tab-item-content.active{
  padding: 20px;
  height: 300px;
  display: block;

li.tab .hidden-tab-name{
  font-size: 0;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s, opacity 0.5s linear;
li.tab.active-item .hidden-tab-name{
  display: inline;
  visibility: visible;
  opacity: 1; /*where 1 is opaque and 0 is entirely transparent. */
  font-size: inherit;

              'use strict';

 * Let's Reference the DOM elements
let	tab = document.getElementsByClassName('tab'),
		tabContent = document.getElementsByClassName('tab-item-content'),
		selector = document.querySelector('.selector'),
		tabs = document.querySelector('.tabs');

 * Let's create a function that can by default hide an inactive tab's title.
function hideTabsContent(a) {
		for (let i = a; i < tabContent.length; i++) {

selector.style.width = (tab[0].offsetWidth + 'px');

 * Let's listen to click events of our tabs
tabs.addEventListener('click', function () {
	let target = event.target;
	if (target.className === 'tab') {
		for (let i = 0; i < tab.length; i++) {
			if (target === tab[i]) {
				selector.style.left = (target.offsetLeft + 'px');
				selector.style.width = (target.offsetWidth + 'px');

function showTabsContent(b) {

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................