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 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

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

              
                <h1>CSS-Only Tabs</h1>

<div class="tabs" role="tablist">
	<div class="tab" role="tab">
		<input type="radio" name="radioTab" id="tab-1" checked>
		<label for="tab-1">Ilvermorny</label>
		<div class="content" tabindex="0">
			<p>If you fancy living a Hogwarts-style life across the pond. The founder of Ilvermorny, Isolt Sayre, always wished she could go to Hogwarts, and the school definitely seems to embody some of its traditions.</p>
		</div>
	</div>

	<div class="tab" role="tab">
		<input type="radio" name="radioTab" id="tab-2">
		<label for="tab-2">Hogwarts</label>
		<div class="content" tabindex="0">
			<p>Because you love it. But also because of its detailed history, secret passages, eccentric professors, wisecracking ghosts, lovely house-elves, talking portraits and much, much more besides. Most importantly, Hogwarts seems to have a sense of humour
				about itself, and round every corner is a new delight.</p>
		</div>
	</div>

	<div class="tab" role="tab">
		<input type="radio" name="radioTab" id="tab-3">
		<label for="tab-3">Durmstrang</label>
		<div class="content" tabindex="0">
			<p>You’ll certainly hear a few interesting stories at Durmstrang, seeing as this is the school that Dark wizard Gellert Grindelwald was expelled from.</p>
		</div>
	</div>
</div>
              
            
!

CSS

              
                .tabs {
	position: relative;
	display: flex;
	align-items: flex-start;
	min-height: 200px;
	width: 80vw;
	max-width: 30em;
	margin: 2em;
}

.tab {
	display: flex;
	flex-direction: column;

	label {
		padding: 1em;
		background-color: #0094a7;
		color: #fff;
		border: none;
		border-radius: 6px 6px 0 0;
		font-size: 1em;
		font-family: sans-serif;
		cursor: pointer;
	}

	/* hide the radio buttons visually*/
	[type="radio"] {
		position: absolute;
		height: 0;
		width: 0;
		overflow: hidden;
		clip: rect(0, 0, 0, 0);

		/* change color of active tab */
		&:checked ~ label {
			background: #007584;
		}

		/* makes the active tab's content visible */
		&:checked ~ label ~ .content {
			opacity: 1;
			z-index: 1; /* increase the z-index so the content is in focus*/
		}

		&:focus + label {
			outline: 2px dotted black;
		}

		/* trick to avoid focus line on click*/
		&:focus:not(:focus-visible) + label {
			outline: 2px dotted transparent;
		}
	}
}

.content {
	height: 100%;
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	top: 3em;
	width: 100%;
	height: 100%;
	background: azure;
	border: 1px solid #007584;
	border-radius: 0 6px 6px;
	padding: 1em 1.2em;
	font-family: sans-serif;
	line-height: 1.5;
	color: #333;
	z-index: -1;
	opacity: 0; /* hides the tab content by default */

	p {
		margin: 0;
	}
}

body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

h1 {
	font-size: 3em;
	color: #015863;
	font-family: "Berkshire Swash", cursive;
	text-align: center;
	margin-bottom: 2em;
}

              
            
!

JS

              
                /* There's nothing here. Zero. Zilch. Nada. */
              
            
!
999px

Console