Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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="page-content">
	<p>This is my solution for css-only tabs. It's not perfect, but has some advantages, like some degree of flexibility - the CSS is id-agnostic, so the HTML can be generated by server-side scripts (for example in WordPress shortcodes).</p>
	<p>All you need to generate are the radio buttons' ids and names.</p>
	
	<div class="tabbed">
		<input type="radio" id="tab1" name="css-tabs" checked>
		<input type="radio" id="tab2" name="css-tabs">
		<input type="radio" id="tab3" name="css-tabs">
		
		<ul class="tabs">
			<li class="tab"><label for="tab1">Gangsta lipsum</label></li>
			<li class="tab"><label for="tab2">Zombie lipsum</label></li>
			<li class="tab"><label for="tab3">New age bullshit</label></li>
		</ul>
		
		<div class="tab-content">
			<h4>Gangsta lipsum</h4>
			<p>Da bomb ipsizzle dolizzle sit amizzle, consectetuer adipiscing fo shizzle. Nullam yo velizzle, aliquet volutpizzle, fo shizzle yippiyo, for sure vizzle, arcu. Black eget fo shizzle. Sizzle erizzle. Rizzle at dolizzle dapibizzle turpis tempizzle izzle. Maurizzle crackalackin nibh et check out this. Cool check it out tortizzle. Break it down bling bling rhoncizzle my shizz. Fo hizzle rizzle platea boom shackalack. Gangsta dapibus. Owned tellus urna, pretizzle black, mattizzle ac, eleifend for sure, nunc. Owned suscipizzle. Integizzle sempizzle shiz sed purizzle.</p>
		</div>
		
		<div class="tab-content">
			<h4>Zombie lipsum</h4>
			<p>Zombie ipsum brains reversus ab cerebellum viral inferno, brein nam rick mend grimes malum cerveau cerebro. De carne cerebro lumbering animata cervello corpora quaeritis. Summus thalamus brains sit​​, morbo basal ganglia vel maleficia? De braaaiiiins apocalypsi gorger omero prefrontal cortex undead survivor fornix dictum mauris. </p>
		</div>
		
		<div class="tab-content">
			<h4>New age bullshit</h4>
			<p>Our conversations with other pilgrims have led to an awakening of pseudo-astral consciousness. Who are we? Where on the great myth will we be re-energized? We are at a crossroads of complexity and stagnation.</p>
			<p>Eons from now, we dreamers will exist like never before as we are aligned by the cosmos. We are being called to explore the stratosphere itself as an interface between nature and complexity. We must learn how to lead infinite lives in the face of bondage.</p>
			<p>Generated by the <a href="http://sebpearce.com/bullshit/">New Age Bullshit Generator</a></p>
		</div>
	</div>
	<p>The tabs are quite easy to use as they don't need absolute positioning and min-heights.</p>
	<p>They can also be used multiple times in one document without any influence on CSS.</p>
	<div class="tabbed">
		<input type="radio" id="tab21" name="css-tabs2" checked>
		<input type="radio" id="tab22" name="css-tabs2">
		<input type="radio" id="tab23" name="css-tabs2">
		
		<ul class="tabs">
			<li class="tab"><label for="tab21">Gangsta lipsum</label></li>
			<li class="tab"><label for="tab22">Zombie lipsum</label></li>
			<li class="tab"><label for="tab23">New age bullshit</label></li>
		</ul>
		
		<div class="tab-content">
			<h4>Gangsta lipsum</h4>
			<p>Da bomb ipsizzle dolizzle sit amizzle, consectetuer adipiscing fo shizzle. Nullam yo velizzle, aliquet volutpizzle, fo shizzle yippiyo, for sure vizzle, arcu. Black eget fo shizzle. Sizzle erizzle. Rizzle at dolizzle dapibizzle turpis tempizzle izzle. Maurizzle crackalackin nibh et check out this. Cool check it out tortizzle. Break it down bling bling rhoncizzle my shizz. Fo hizzle rizzle platea boom shackalack. Gangsta dapibus. Owned tellus urna, pretizzle black, mattizzle ac, eleifend for sure, nunc. Owned suscipizzle. Integizzle sempizzle shiz sed purizzle.</p>
		</div>
		
		<div class="tab-content">
			<h4>Zombie lipsum</h4>
			<p>Zombie ipsum brains reversus ab cerebellum viral inferno, brein nam rick mend grimes malum cerveau cerebro. De carne cerebro lumbering animata cervello corpora quaeritis. Summus thalamus brains sit​​, morbo basal ganglia vel maleficia? De braaaiiiins apocalypsi gorger omero prefrontal cortex undead survivor fornix dictum mauris. </p>
		</div>
		
		<div class="tab-content">
			<h4>New age bullshit</h4>
			<p>Our conversations with other pilgrims have led to an awakening of pseudo-astral consciousness. Who are we? Where on the great myth will we be re-energized? We are at a crossroads of complexity and stagnation.</p>
			<p>Eons from now, we dreamers will exist like never before as we are aligned by the cosmos. We are being called to explore the stratosphere itself as an interface between nature and complexity. We must learn how to lead infinite lives in the face of bondage.</p>
			<p>Generated by the <a href="http://sebpearce.com/bullshit/">New Age Bullshit Generator</a></p>
		</div>
	</div>
	<p>Unfortunately, these tabs have one downside: limited tab count. The limit is set in the CSS (see comments in the CSS code). But let's get real: who uses lots of tabs?</p>
	<p>And one more thing: no animation to prevent annoying page jumps.</p>
	<p>Have an improvement idea? Feel free to suggest it in the comments!</p>
</div>
              
            
!

CSS

              
                body {
	background-image: linear-gradient(19deg, #21D4FD 0%, #B721FF 100%);
ccc; 
	background-repeat: no-repeat;
	font: 400 16px/1.5em "Open Sans", sans-serif;
}
.page-content {
	max-width: 700px; 
	margin: 32px auto; 
	padding: 32px; 
	background: #fff;
}
a {
	color: #21D4FD; 
	transition: all 0.3s;
}
a:hover {
	color: #B721FF;
}

.tabbed {
	overflow-x: hidden; /* so we could easily hide the radio inputs */
	margin: 32px 0;
	padding-bottom: 16px;
	border-bottom: 1px solid #ccc;
}

.tabbed [type="radio"] {
	/* hiding the inputs */
	display: none;
}

.tabs {
	display: flex;
	align-items: stretch;
	list-style: none;
	padding: 0;
	border-bottom: 1px solid #ccc;
}
.tab > label {
	display: block;
	margin-bottom: -1px;
	padding: 12px 15px;
	border: 1px solid #ccc;
	background: #eee;
	color: #666;
	font-size: 12px; 
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 1px;
	cursor: pointer;	
	transition: all 0.3s;
}
.tab:hover label {
	border-top-color: #333;
	color: #333;
}

.tab-content {
	display: none;
	color: #777;
}

/* As we cannot replace the numbers with variables or calls to element properties, the number of this selector parts is our tab count limit */
.tabbed [type="radio"]:nth-of-type(1):checked ~ .tabs .tab:nth-of-type(1) label,
.tabbed [type="radio"]:nth-of-type(2):checked ~ .tabs .tab:nth-of-type(2) label,
.tabbed [type="radio"]:nth-of-type(3):checked ~ .tabs .tab:nth-of-type(3) label,
.tabbed [type="radio"]:nth-of-type(4):checked ~ .tabs .tab:nth-of-type(4) label,
.tabbed [type="radio"]:nth-of-type(5):checked ~ .tabs .tab:nth-of-type(5) label {
	border-bottom-color: #fff;
	border-top-color: #B721FF;
	background: #fff;
	color: #222;
}

.tabbed [type="radio"]:nth-of-type(1):checked ~ .tab-content:nth-of-type(1),
.tabbed [type="radio"]:nth-of-type(2):checked ~ .tab-content:nth-of-type(2),
.tabbed [type="radio"]:nth-of-type(3):checked ~ .tab-content:nth-of-type(3),
.tabbed [type="radio"]:nth-of-type(4):checked ~ .tab-content:nth-of-type(4) {
	display: block;
}
              
            
!

JS

              
                
              
            
!
999px

Console