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 URL's 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 it's URL and the proper URL extention.
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="container">
<!-- Tab 1 -->
<input type="radio" id="tab-link-1" name="tabset" checked>
<label for="tab-link-1">Tab 1</label>
<input type="radio" id="tab-link-2" name="tabset">
<label for="tab-link-2">Tab 2</label>
<input type="radio" id="tab-link-3" name="tabset">
<label for="tab-link-3">Tab 3</label>
<!-- Tab content -->
<div class="tab-content">
<section class="tab-panel" id="tab-1">
<h2>Tab 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut tempor, velit et tempor molestie, urna purus fringilla neque, nec condimentum purus nibh eu tortor. Curabitur non maximus mi. Suspendisse cursus libero nisi, ac imperdiet purus malesuada vel. Cras maximus in quam vel sagittis. Sed ut cursus turpis. Mauris a ipsum congue, sagittis risus commodo, tincidunt mi. Sed mi ante, viverra et iaculis sollicitudin, malesuada vitae turpis. Proin nisl neque, semper a nisl et, dictum feugiat nulla.</p>
<p>Praesent sit amet molestie nunc. In nec tellus cursus, malesuada urna quis, tristique nisl. Vivamus iaculis tempus libero. Mauris nec elit semper, volutpat dolor eu, gravida mauris. Maecenas sed ullamcorper justo. Cras sit amet massa augue. Nam posuere nec justo at auctor.</p>
</section>
<section class="tab-panel" id="tab-2">
<h2>Tab 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec accumsan elit, et eleifend odio. Integer sed mi vel enim dapibus congue. Proin consequat augue sed tellus egestas gravida. Curabitur vel nibh sit amet metus semper rutrum. Etiam augue ex, aliquam sed convallis vitae, vulputate non diam. Aenean tempus diam in cursus interdum. Mauris tincidunt accumsan leo, eget mattis ex mattis eget.</p>
<p>Aliquam ligula erat, tristique vitae orci eu, tristique semper velit. Suspendisse scelerisque et nisl quis convallis. Maecenas at libero ipsum. Quisque elementum metus id mauris pretium, bibendum auctor libero tincidunt. Cras dolor diam, faucibus vel massa eu, vestibulum bibendum lorem. Cras vel massa vitae ipsum dapibus imperdiet vel eu magna. Morbi ac augue non nibh ullamcorper.</p>
</section>
<section class="tab-panel" id="tab-3">
<h2>Tab 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies risus vel nibh malesuada, ut ultricies massa sagittis. Proin vestibulum bibendum velit, in congue neque eleifend eget. Vivamus quis turpis non odio tempus dapibus quis et ligula. Mauris molestie tincidunt tellus, sed interdum est egestas sed. Sed id ligula neque. Sed consequat venenatis metus a faucibus. Morbi mauris nulla, finibus at laoreet a, interdum sit amet dui. Cras convallis purus arcu, ut feugiat odio mattis vitae. Aliquam fringilla justo quis sagittis lobortis.</p>
<p>Quisque suscipit pulvinar nunc, at auctor turpis. Nullam ex turpis, fringilla ut blandit vel, laoreet id turpis. Etiam velit ex, laoreet et felis eu, placerat tincidunt sem. Praesent ut ex ipsum. Suspendisse potenti. Quisque imperdiet lorem sit amet varius condimentum. Quisque id rhoncus nibh, vel semper velit. Class aptent taciti.</p>
</section>
</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Overpass:wght@200;300;400;500;600;700&family=Open+Sans:wght@300;400;500;600;700&display=swap");
*, *::before, *::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background-color: #fff;
font-family: "Overpass", "Open Sans", Helvetica, sans-serif;
font-size: 1rem;
font-weight: 300;
line-height: 1.5em;
color: #333;
position: relative;
}
.container {
max-width: 65em;
margin: 30px;
}
.container > input[type="radio"] {
position: absolute;
left: -200vw;
}
.container > label {
position: relative;
display: inline-block;
padding: 15px 15px 25px;
border: 1px solid transparent;
border-bottom: 0;
cursor: pointer;
font-weight: 600;
}
.container > label::after {
content: "";
position: absolute;
left: 15px;
bottom: 10px;
width: 22px;
height: 4px;
background: #8d8d8d;
}
.container > label:hover, .container > input:focus + label {
color: #06c;
}
.container > label:hover::after, .container > input:focus + label::after, .container > input:checked + label::after {
background: #06c;
}
.container > input:checked + label {
border-color: #ccc;
border-bottom: 1px solid #fff;
margin-bottom: -1px;
}
.tab-content {
border-top: 1px solid #ccc;
}
.tab-content section.tab-panel {
padding: 30px 0;
}
/* The magic */
.container section.tab-panel {
display: none;
}
.container > input:first-child:checked ~ .tab-content > section.tab-panel:first-child, .container > input:nth-child(3):checked ~ .tab-content > section.tab-panel:nth-child(2), .container > input:nth-child(5):checked ~ .tab-content > section.tab-panel:nth-child(3) {
display: block;
}
Also see: Tab Triggers