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.

              <!-- Lets Contain this -->
<div id="tab-system-container">

			 This will be our sample.
			 Don't worry each tab is the same.
			 Why a span you may ask? Well,
			 actually it doesnt matter what you use.
			 This is simply our anchor point so when
			 we make a selection our page doesnt jump
			 and scroll all over the place! We keep
			 this hidden with CSS.
	<span id="tab-two" class="tab-target"></span>
			 This is our tab, button, anchor.
			 What you call it is up to you. The key
			 is that it must be an anchor element.
			 Anchors allow us to :target IDs on
			 click. It is pretty awesome! Now it is
			 not just for jumping around the page!
	<a href="#tab-two" class="tab">The Journey</a>
			 This is our hidden data, ooh, spooky.
			 We can fill this up with whatever we want,
			 I dont care how you make it look, just know
			 that this will be hidden when you change tabs.
	<div id="tab-two-data" class="tab-data">
		<h1>The Journey</h1>
		<p>My first implementation of a pure CSS tab system made use of some amazing trickery using radio buttons. You may have played with this before but using lables, radio buttons, and some good cascading elements. However you will come to discover it is nearly impossible to do much without tagging each individual radio button in your CSS. That is far from optimal. So I pressed on...</p>

	<!-- More of the same - Add as many as you like. -->
	<span id="tab-three" class="tab-target"></span>
	<a href="#tab-three" class="tab">The Discovery</a>
	<div id="tab-three-data" class="tab-data">
		<h1>The Mighty :target</h1>
		<p>In my journey when I was tired and alone, I moved on to a new project; can you style something you target with an anchor? This never crossed my mind, so I ventured in another direction and found the all mighty :target psuedo class name.</p>
		<p>What a beautiful psuedo class, I can target elements on a page with an anchor and no javascript? The number of amazing things I could do! Then it clicked...</p>
	<span id="tab-four" class="tab-target"></span>
	<a href="#tab-four" class="tab">Study</a>
	<div id="tab-four-data" class="tab-data">
		<h1>Studying is Key</h1>
		<p>I started to play and toy, making things pop in, and pop out at a click of a button. Targeting #! with an anchor let me reset styles. How amazing! But that amazement was short lived.</p>
		<p>I wanted to see if I could apply this to replace my tab system using radio at the moment. I pondered, I toyed, I discovered. I learned I could stack things in a certain way and apply all my styles without tagging each individual element. How cool is that!</p>
		<p>It started as a simple list of anchors and boxes that would appear when clicked and switch when the next anchor was pressed. But then I wondered, can I have one element appear on page load?</p>
	<span id="tab-five" class="tab-target"></span>
	<a href="#tab-five" class="tab">The Fight</a>
	<div id="tab-five-data" class="tab-data">
		<h1>War. War never changes.</h1>
		<p>I fought, tooth and nail.</p>
		<p>You can't go up the cascading styles, it is just not possible... Why W3 Gods, WHY!</p>
		<p>Wait a minute... What if I put the first tab at the end? Then I can fix the ordering in flex!</p>
		<p>But CSS beat me back when I discovered hovering on the first element was impossible when I had it targeted to not show as clicked. :target supercedes :hover, really?</p>
		<p>Days, Weeks, went by and I felt stuck. Why go on?</p>
	<span id="tab-six" class="tab-target"></span>
	<a href="#tab-six" class="tab">The Victory</a>
	<div id="tab-six-data" class="tab-data">
		<p>After lying dead on the battlefield a wise man came across me on Gitter and said in a calming tone, "Why not try adding !important to the :hover". I couldent wait to try it, I shot up and pushed on, and by golly it WORKED! What a fool I was!</p>
		<p>The product before you is the results of this harrowing journey. I hope you put it to good use.</p>
			 This my friend is a reset.
			 Please remove before flight.
	<a href="#!" class="tab">No Target</a>
			 Why the hell is your first item all the
			 way at the end? Well... Because you can't
			 cascade styles upwards. In order for this
			 to appear at the start we need it at the
			 bottom. Figure that out W3! We will fix
			 the ordering with some nice display:flex.
	<span id="tab-one" class="tab-target"></span>
	<a href="#tab-one" class="tab">Introductions</a>
	<div id="tab-one-data" class="tab-data">
		<h1>Pure CSS Tab System using :target</h1>
		<p>Pretty crazy eh? I swear, no JS was used in the making of this system.</p>
		<p>Follow along the tabs to learn about how this works!</p>

<!-- That is it, you can look at the CSS now. -->
              /* Basic Appearence Stuff #IGNORE */
body {background-color: tan;}
* {font-family: helvetica, arial, sans-serif;}
p {font-size: 1.1713030747vw;}
h1 {font-size: 2.3426061493vw;}
@media screen and (max-width: 1366px) {
	p {font-size: 1rem;}
	h1 {font-size: 2rem;}
/* Tab Styling - Self Evident */
#tab-system-container {
	width: 80%;
	margin: 0 auto;
/* In order for the :hover style to work
on the first tab you must make these
all !important, I am super cereal! */
.tab:hover {
	box-shadow: inset 0 0 0.7501vw 0.15vw #ffffff !important;
	transition: box-shadow 0.2s ease !important;
/* Isn't it so pretty? */
.tab {
	margin: 10px;
	padding: 0.9002vw 1.3503vw;
	border-radius: 10px;
	color: green;
	font-weight: 600;
	box-shadow: inset 0 transparent;
	background-color: orange;
	text-decoration: none;
	transition: box-shadow 0.2s ease;
/* Okay I am not great with visual design */
.tab-data {
	margin: 0 10px 10px;
	padding: 30px;
	background-color: orange;
	color: green;
	border-radius: 12px;

/* Fix Order */
#tab-system-container {
	display: flex;
	flex-flow: row wrap;
	justify-content: center;
/* This is where we put all the
tabs at the end of the list. */
.tab {
	order: 2;
/* This puts the last tab to
the front of the list. */
.tab:last-of-type {
	order: 1;
/* This makes sure the tab data
stays under the tabs. */
.tab-data {
	flex-basis: 100%;
	order: 3;

/* Logic for
Displaying Data */
/* Hide those pesky spans. */
.tab-target {
	display: none;
/* Begin hiding tab data. */
.tab-data {
	display: none;
/* Two functions:
One: If the span is targeted, then move
to the adjacent anchor, then to the adjacent
div, tada, now make it show!
Two: If the last span is not targeted then
move to the last span's adjacent anchor, then
to the adjacent div. First tab is now visible. */
.tab-target:target + .tab + .tab-data,
.tab-target:last-of-type:not(:target) + .tab + .tab-data {
	display: block;
/* If the span is not the last one and it
is targeted, then jump to the last anchor
and then to the adjacent div and make it
dissapear! It is like magic! */
.tab-target:not(:last-of-type):target ~ .tab:last-of-type + .tab-data {
	display: none;

/* Logic for
Stlying Tabs */
/* Similar to above, two functions:
One: If the span is targeted, move to the
adjacent anchor and apply this style.
Two: If the span is not the targer, jump
to the last anchor and apply this style.
This makes sure the first tab is styled at
load of the page. */
.tab-target:target + .tab,
.tab-target:not(:target) ~ .tab:last-of-type{
	box-shadow: inset 0 0 0.7501vw 0.15vw #ffffff;
/* Lastly, if the span is not the last and it
is targeted, then jump to the last anchor and
apply the following style. All done! */
.tab-target:not(:last-of-type):target ~ .tab:last-of-type {
	box-shadow: none;

/* Seriously, that is it, start using it! */
🕑 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 ..................