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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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.
<label class="toggle happy-sad">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle love-hate">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle nerd-cool">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle young-old">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle male-female">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle king-queen">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle sun-moon">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle fire-water">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle heart-break">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle bomb-explode">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle egg-shell-fry">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle takeoff-land">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle hourglass-start-end">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle speaker-low-high">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle lock-unlock">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle chick-chicken">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle cow-milk">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle pig-bacon">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle fish-sushi">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle caterpillar-butterfly">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle seedling-flower">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle thumbs-up-down">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle left-right">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
<label class="toggle up-down">
<input type="checkbox" class="toggle-checkbox">
<div class="toggle-btn"></div>
</label>
:root {
font-size: calc(5em + 20vw);
}
* {
box-sizing: border-box;
}
body {
display: flex;
justify-content: center;
align-content: center;
align-items: center;
flex-wrap: wrap;
min-height: 100vh;
overflow-x: hidden;
background-color: #13fccd;
}
.toggle {
position: relative;
width: 1em;
height: 0.1em;
border-radius: 0.5em;
border: 0.015em solid #9f9f9f;
background-image: linear-gradient(#f2f2f2, #fff, #f2f2f2);
margin: 0.26em 0.15em;
cursor: pointer;
filter: drop-shadow(0.015em 0.015em 0.01em rgba(0, 0, 0, 0.3))
}
.toggle-btn::after {
position: absolute;
top: -0.14rem;
left: 0;
width: 50%;
font-size: 0.35em;
text-align: center;
transition: all 500ms cubic-bezier(0.34, 0.78, 0.55, 1.4);
}
.toggle-checkbox {
position: absolute;
visibility: hidden;
}
.toggle-checkbox:checked + .toggle-btn::after {
left: 50%;
}
/* Happy/Sad Toggle */
.happy-sad .toggle-btn::after {
content: 'š';
}
.happy-sad .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Love/Hate Toggle */
.love-hate .toggle-btn::after {
content: 'š';
}
.love-hate .toggle-checkbox:checked + .toggle-btn::after {
content: 'š”';
}
/* Nerd/Cool Toggle */
.nerd-cool .toggle-btn::after {
content: 'š¤';
}
.nerd-cool .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Young/Old Toggle */
.young-old .toggle-btn::after {
content: 'š¶';
}
.young-old .toggle-checkbox:checked + .toggle-btn::after {
content: 'š“';
}
/* Male/Female Toggle */
.male-female .toggle-btn::after {
content: 'šØ';
}
.male-female .toggle-checkbox:checked + .toggle-btn::after {
content: 'š©';
}
/* King/Queen Toggle */
.king-queen .toggle-btn::after {
content: 'š¤“';
}
.king-queen .toggle-checkbox:checked + .toggle-btn::after {
content: 'šø';
}
/* Sun/Moon Toggle */
.sun-moon .toggle-btn::after {
content: 'š';
}
.sun-moon .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Fire/Water Toggle */
.fire-water .toggle-btn::after {
content: 'š„';
}
.fire-water .toggle-checkbox:checked + .toggle-btn::after {
content: 'š§';
}
/* Heart/Break Toggle */
.heart-break .toggle-btn::after {
content: 'š';
}
.heart-break .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Bomb/Explode Toggle */
.bomb-explode .toggle-btn::after {
content: 'š£';
}
.bomb-explode .toggle-checkbox:checked + .toggle-btn::after {
content: 'š„';
}
/* Egg Shell/Fry Toggle */
.egg-shell-fry .toggle-btn::after {
content: 'š„';
}
.egg-shell-fry .toggle-checkbox:checked + .toggle-btn::after {
content: 'š³';
}
/* Takeoff/Land Toggle */
.takeoff-land .toggle-btn::after {
content: 'š«';
}
.takeoff-land .toggle-checkbox:checked + .toggle-btn::after {
content: 'š¬';
}
/* Hourglass Start/End Toggle */
.hourglass-start-end .toggle-btn::after {
content: 'ā³';
}
.hourglass-start-end .toggle-checkbox:checked + .toggle-btn::after {
content: 'ā';
}
/* Speaker Low/High Toggle */
.speaker-low-high .toggle-btn::after {
content: 'š';
}
.speaker-low-high .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Lock/Unlock Toggle */
.lock-unlock .toggle-btn::after {
content: 'š';
}
.lock-unlock .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Chick/Chicken Toggle */
.chick-chicken .toggle-btn::after {
content: 'š£';
}
.chick-chicken .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Cow/Milk Toggle */
.cow-milk .toggle-btn::after {
content: 'š';
}
.cow-milk .toggle-checkbox:checked + .toggle-btn::after {
content: 'š„';
}
/* Pig/Bacon Toggle */
.pig-bacon .toggle-btn::after {
content: 'š';
}
.pig-bacon .toggle-checkbox:checked + .toggle-btn::after {
content: 'š„';
}
/* Fish/Sushi Toggle */
.fish-sushi .toggle-btn::after {
content: 'š';
}
.fish-sushi .toggle-checkbox:checked + .toggle-btn::after {
content: 'š£';
}
/* Caterpillar/Butterfly Toggle */
.caterpillar-butterfly .toggle-btn::after {
content: 'š';
}
.caterpillar-butterfly .toggle-checkbox:checked + .toggle-btn::after {
content: 'š¦';
}
/* Seedling/Flower Toggle */
.seedling-flower .toggle-btn::after {
content: 'š±';
}
.seedling-flower .toggle-checkbox:checked + .toggle-btn::after {
content: 'š·';
}
/* Thumbs Up/Down Toggle */
.thumbs-up-down .toggle-btn::after {
content: 'š';
}
.thumbs-up-down .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Left/Right Toggle */
.left-right .toggle-btn::after {
content: 'š';
}
.left-right .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/* Up/Down Toggle */
.up-down .toggle-btn::after {
content: 'š';
}
.up-down .toggle-checkbox:checked + .toggle-btn::after {
content: 'š';
}
/*
ā£āāš
āāš
āšā£ā
āāš
šš
*/
Also see: Tab Triggers