HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="page-wrap">
<h1>
Pure CSS Tab
</h1>
<ul class="tab-wrap">
<li>
<input type="radio" id="tab-1" name="tab" checked />
<label for="tab-1" class="label-1">
Tab 1
</label>
<article class="tab-content">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quisquam laboriosam voluptatem optio cupiditate aliquam culpa doloremque perspiciatis unde blanditiis repellendus consequuntur rerum accusamus, minus pariatur voluptatum assumenda ad adipisci esse!
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad reprehenderit, ducimus tempore quidem iste quisquam! Illum voluptatibus ad rerum possimus quisquam distinctio, quaerat quod beatae quas, soluta, vel esse consequatur!
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Labore, illo itaque ratione tempore eius eos ab, aperiam, repellendus sequi, qui et. Nobis repellat, qui voluptate iste asperiores temporibus provident ex.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cum laboriosam porro eum ea eos nihil a dolores corrupti libero, nobis, sequi voluptatum? Unde accusamus laborum ex reiciendis quibusdam aliquam repellat.
</p>
</article>
</li>
<li>
<input type="radio" id="tab-2" name="tab" />
<label for="tab-2" class="label-2">
Tab 2
</label>
<article class="tab-content">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis, culpa molestias delectus incidunt cum sed impedit aperiam aspernatur aliquam eos. Provident velit minus quia ea amet. Reprehenderit, voluptatem, explicabo. Consequuntur.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quis amet repellat, nam. Beatae consequatur ratione quas omnis similique, alias, doloremque quam soluta rem libero eum error nesciunt maxime iure deleniti!
</p>
<p>
Assumenda rerum dolorum sapiente, voluptatibus nobis dolore debitis autem sed eos inventore odio provident quae molestiae quibusdam voluptate dicta neque, quisquam necessitatibus, expedita aliquam earum alias corrupti! Maxime, quia deleniti!
</p>
<p>
Quidem sunt quae cumque laborum incidunt commodi nam impedit cupiditate molestiae quia, aperiam hic nobis ullam esse neque natus saepe provident excepturi sed, iusto similique fuga libero nisi quod mollitia.
</p>
<p>
Atque voluptas doloremque vel, reprehenderit molestiae modi corrupti assumenda vitae at totam accusamus a autem consectetur, expedita veniam ut sapiente distinctio aliquid eum rerum eos accusantium dolor voluptatibus. Consectetur, voluptate.
</p>
</article>
</li>
<li>
<input type="radio" id="tab-3" name="tab" />
<label for="tab-3" class="label-3">
Tab 3
</label>
<article class="tab-content">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Omnis, culpa molestias delectus incidunt cum sed impedit aperiam aspernatur aliquam eos. Provident velit minus quia ea amet. Reprehenderit, voluptatem, explicabo. Consequuntur.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Unde itaque consequatur sequi repellendus, ipsa quo neque. A eaque veritatis earum, aliquid dolorum itaque tempore, aliquam eum, culpa expedita doloremque nihil.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Numquam, sapiente. Doloremque quos eius consequuntur alias perspiciatis ratione deserunt soluta nulla sequi, nihil iste sint debitis ea, doloribus eos non. Eligendi?
</p>
</article>
</li>
</ul>
</div>
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,800);
*, *:after, *:before {
box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
font-family: 'Open Sans', sans-serif;
background: #333;
}
.page-wrap {
width: 80%;
margin: 0 auto;
}
h1 {
font-size: 2rem;
font-weight: bold;
padding: 0;
margin: 20px 0;
color: #fff;
text-align: center;
}
p {
font-size: 1rem;
line-height: 1.5rem;
}
input[type="radio"] {
position: absolute;
top: -9999px;
left: -9999px;
}
.tab-wrap {
width: 100%;
float: none;
list-style: none;
position: relative;
margin: 0 auto;
padding: 0;
text-align: left;
}
.tab-wrap li {
float: left;
display: block;
}
.tab-wrap label {
position: relative;
display: inline-block;
padding: 1.5em 1.5em 1em;
color: inherit;
text-decoration: none;
margin: 0 10px 0 0px;
}
.label-1 {
z-index: 100;
}
.label-2 {
z-index: 90;
}
.label-3 {
z-index: 80;
}
.tab-wrap label:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 10px;
left: 0;
z-index: -1;
border: .1em solid #aaa;
border-bottom: none;
border-radius: 10px 10px 0 0;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,1)), color-stop(100%,rgba(229,229,229,1)));
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%,rgba(229,229,229,1) 100%);
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(229,229,229,1) 100%);
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%,rgba(229,229,229,1) 100%);
-webkit-transform: perspective(5px) rotateX(2deg);
transform: perspective(5px) rotateX(2deg);
-webkit-transform-origin: left;
-ms-transform-origin: left;
transform-origin: left;
}
.tab-wrap .tab-content {
z-index: 200;
display: none;
overflow: hidden;
width: 100%;
position: absolute;
top: 53px;
left: 0;
padding: 20px;
background: #fff;
border-radius: 3px;
border: .1em solid #aaa;
border-top: 0;
}
.tab-wrap [id^="tab"]:checked + label {
z-index: 200;
margin-bottom: -1px;
border-top-width: 1px;
}
.tab-wrap [id^="tab"]:checked + label:before {
background: #fff;
}
.tab-wrap [id^="tab"]:checked ~ .tab-content{
display: block;
}
Also see: Tab Triggers