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.
<div class="accordion-tabs">
<!-- Toggle radio buttons -->
<input type="radio" name="tabs-activate" id="tab-one" class="activate-tab" checked />
<input type="radio" name="tabs-activate" id="tab-two" class="activate-tab" />
<input type="radio" name="tabs-activate" id="tab-three" class="activate-tab" />
<div class="tabs">
<!-- Visible tabs -->
<label for="tab-one" id="tab-one-label" class="tab">Tab One</label>
<label for="tab-two" id="tab-two-label" class="tab">Tab Two</label>
<label for="tab-three" id="tab-three-label" class="tab">Tab Three</label>
<!-- Tab content -->
<div id="tab-one-tab-content" class="tab-content active">
<h3>Spit up on light gray carpet instead of adjacent linoleum</h3>
<p>Sit and stare wake up human for food at 4am or attack feet. All of a sudden cat goes crazy you call this cat food. Sleep in the bathroom sink with tail in the air hiss and stare at nothing then run suddenly away or climb leg. Scratch me there, elevator
butt unwrap toilet paper plan steps for world domination scratch at the door then walk away so human is washing you why halp oh the horror flee scratch hiss bite and lick the plastic bag climb a tree, wait for a fireman jump to fireman then scratch
his face. Eat a plant, kill a hand spot something, big eyes, big eyes, crouch, shake butt, prepare to pounce cats making all the muffins yet present belly, scratch hand when stroked tuxedo cats always looking dapper. Pooping rainbow while flying
in a toasted bread costume in space get video posted to internet for chasing red dot cat slap dog in face and scratch the box love to play with owner's hair tie or lick plastic bags chase ball of string. When in doubt, wash kitty loves pigs cats
go for world domination yet chase after silly colored fish toys around the house so if it smells like fish eat as much as you wish. Scratch leg; meow for can opener to feed me scratch leg; meow for can opener to feed me so hide when guests come
over poop in litter box, scratch the walls for under the bed, but meow meow yet eats owners hair then claws head. Touch water with paw then recoil in horror. </p>
</div>
<div id="tab-two-tab-content" class="tab-content">
<h3>Soft kitty warm kitty little ball of furr plan steps for world domination</h3>
<p>I like big cats and i can not lie gnaw the corn cob. Pee in human's bed until he cleans the litter box. Jump around on couch, meow constantly until given food, going to catch the red dot today going to catch the red dot today put butt in owner's
face has closed eyes but still sees you yet kitty scratches couch bad kitty if it smells like fish eat as much as you wish yet poop on grasses. Rub whiskers on bare skin act innocent the dog smells bad chase ball of string. Relentlessly pursues
moth kick up litter pounce on unsuspecting person purrrrrr. Lie on your belly and purr when you are asleep. Hide from vacuum cleaner peer out window, chatter at birds, lure them to mouth yet meowing chowing and wowing but the dog smells bad so
cats making all the muffins chase ball of string. Chirp at birds my slave human didn't give me any food so i pooped on the floor for tuxedo cats always looking dapper or need to chase tail if it fits, i sits. Hide head under blanket so no one
can see lie on your belly and purr when you are asleep stares at human while pushing stuff off a table all of a sudden cat goes crazy, for stares at human while pushing stuff off a table bathe private parts with tongue then lick owner's face for
intently sniff hand.</p>
</div>
<div id="tab-three-tab-content" class="tab-content">
<h3>Chase imaginary bugs wack the mini furry mouse man running from cops stops to pet cats, goes to jail
</h3>
<p>Hate dog fooled again thinking the dog likes me so show belly wake up human for food at 4am. Walk on car leaving trail of paw prints on hood and windshield kick up litter attack dog, run away and pretend to be victim rub whiskers on bare skin act
innocent lies down wake up wander around the house making large amounts of noise jump on top of your human's bed and fall asleep again. Lick face hiss at owner, pee a lot, and meow repeatedly scratch at fence purrrrrr eat muffins and poutine until
owner comes back.</p>
</div>
</div>
</div>
* {
box-sizing: border-box;
}
.accordion-tabs {
margin: 20px;
// Hide radio buttons
.activate-tab {
position: absolute;
left: -10000px;
}
// Tab container
.tabs {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
// Tabs styling
.tab {
display: inline-block;
padding: 10px;
vertical-align: top;
background-color: #ccc;
cursor: hand;
cursor: pointer;
border-left: 1px solid #fff;
flex-grow: 1;
&:hover {
background-color: #fff;
}
}
// Tab content styling
.tab-content {
background-color: #fff;
padding: 20px 20px 20px 10px;
min-height: 300px;
display: none;
width: 100%;
flex-basis: auto;
}
}
}
// Tab active state styling
#tab-one:checked ~ .tabs #tab-one-label,
#tab-two:checked ~ .tabs #tab-two-label,
#tab-three:checked ~ .tabs #tab-three-label {
background-color: #fff;
cursor: default;
border-left: none;
}
// Tab content active state styling
#tab-one:checked ~ .tabs #tab-one-tab-content,
#tab-two:checked ~ .tabs #tab-two-tab-content,
#tab-three:checked ~ .tabs #tab-three-tab-content {
display: block;
}
// Accordion functionality on screen <768px
@media (max-width: 767px) {
.tabs {
// Switch from tabs to accordion
flex-direction: column;
// Define item order on smaller screen (I would do this in JS instead to remove manual work)
#tab-one {
&-label {
order: 1;
}
&-tab-content {
order: 2;
}
}
#tab-two {
&-label {
order: 3;
}
&-tab-content {
order: 4;
}
}
#tab-three {
&-label {
order: 5;
}
&-tab-content {
order: 6;
}
}
}
// Accordion tab active state styling
#tab-one:checked ~ .tabs #tab-one-label,
#tab-two:checked ~ .tabs #tab-two-label,
#tab-three:checked ~ .tabs #tab-three-label {
background-color: #f8f8f8;
border-bottom: 1px solid #ccc;
}
}
Also see: Tab Triggers