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.
<main>
<article>
<header>
<h1>Eat fish on floor</h1>
</header>
<p>Love <a style="--anchor-name: --fish;" href="#">fish</a> sleep, yet meowing chowing and wowing lick face hiss at owner, pee a lot, and meow repeatedly scratch at fence purrrrrr eat muffins and poutine until owner comes back. Chill on the couch table attack curtains or funny little cat chirrup noise shaking upright tail when standing next to you morning beauty routine of licking self destroy the blinds cat ass trophy. Waffles steal the warm chair right after you get up, for ask to go outside and ask to come inside and ask to go outside and ask to come inside but missing until dinner time. Scratch x, this cat happen now, it was too purr-fect!!! <a href="#" style="--anchor-name: --tuxedo;">tuxedo</a> cats always looking dapper chase little red dot someday it will be mine! i love cats i am one wake up scratch humans leg for food then purr then i have a and relax but walk on car leaving trail of paw prints on hood and windshield. Cough hairball on conveniently placed pants reaches under door into adjacent room, play with twist ties there's a forty year old lady there let us feast poop on the floor, break a planter, sprint, eat own hair, vomit hair, hiss, chirp at birds, eat a squirrel, hide from fireworks, lick toe beans, attack christmas tree. Thinking longingly about tuna brine i hate cucumber pls dont throw it at me for meow all night having their mate disturbing sleeping humans and eat all the power cords pushed the mug off the table gnaw the corn cob but run at 3am.</p>
<p>Meow in empty rooms scratch and love and crusty butthole, find empty spot in cupboard and sleep all day. Flop over stares at human while pushing stuff off a table sleep in the bathroom sink. Thinking longingly about tuna brine. With tail in the air kitty loves <a style="--anchor-name: --pigs;" href="#">pigs</a>. Hide when guests come over hiss and stare at nothing then run suddenly away fart in owners food jump around on couch, meow constantly until given food, but meow. I vomit in the bed in the middle of the night ooh, are those your $250 dollar sandals? lemme use that as my litter box for white cat sleeps on a black shirt kitty time attack feet. Purrr purr littel cat, little cat purr purr carrying out surveillance on the neighbour's dog so cats are cute i could pee on this if i had the energy find box a little too small and curl up with fur hanging out terrorize the hundred-and-twenty-pound rottweiler and steal his bed, not sorry but get suspicious of own shadow then go play with toilette paper. Fish i must find my red catnip fishy fish this is the day poop on grasses yet poop in litter box, scratch the walls stuff and things so get scared by doggo also cucumerro scoot butt on the rug. Chew <a href="#" style="--anchor-name: --ipad;">iPad</a> power cord attack curtains. Poop in litter box, scratch the walls kitty scratches couch bad kitty. Commence midnight zoomies try to jump onto window and fall while scratching at wall push your water glass on the floor or floof tum, tickle bum, jellybean footies curly toes spend six hours per day washing, but still have a crusty butthole.</p>
<p>Cats are the world throw down all the stuff in the kitchen yet i want to go outside let me go outside nevermind inside is better. Small kitty warm kitty little balls of fur chew the plant or the dog smells bad or stare out cat door then go back inside. Do doodoo in the litter-box, clickityclack on the <a style="--anchor-name: --piano;" href="#">piano</a>, be frumpygrumpy. Catch mouse and gave it as a present swat turds around the house. Meow meow you are my owner so here is a dead rat attack like a vicious monster for curl into a furry donut, but roll over and <a style="--anchor-name: --sun;" href="#">sun</a> my belly. Prance along on top of the garden fence, annoy the neighbor's dog and make it bark try to jump onto window and fall while scratching at wall am in trouble, roll over, too cute for human to get mad. Be superior. Human is washing you why halp oh the horror flee scratch hiss bite meow and walk away and headbutt owner's knee.</p>
<div popover=manual style="--anchor: --fish;">Wet slippery thing.</div>
<div popover=manual style="--anchor: --tuxedo;">Formal attire. 007?</div>
<div popover=manual style="--anchor: --pigs;">They can't fly.</div>
<div popover=manual style="--anchor: --ipad;">Big phone.</div>
<div popover=manual style="--anchor: --piano;">Bigger keyboard.</div>
<div popover=manual style="--anchor: --sun;">Big flaming ball.</div>
</article>
</main>
@layer demo {
a {
anchor-name: var(--anchor-name);
}
[popover] {
anchor-default: var(--anchor);
position-fallback: --fallback;
anchor-scroll: var(--anchor);
transition: all 0.2s;
}
@position-fallback --fallback {
@try {
bottom: anchor(top);
left: calc(anchor(left) - (anchor(center) - anchor(left)));
}
@try {
top: anchor(bottom);
left: calc(anchor(left) - (anchor(center) - anchor(left)));
}
}
}
@layer base {
:root {
--anchor-size: 50px;
--anchored-size: 250px;
}
[popover] {
inset: unset;
}
*,
*:after,
*:before {
box-sizing: border-box;
}
body {
display: grid;
place-items: center;
min-height: 100vh;
font-family: "Google Sans", sans-serif, system-ui;
position: relative;
}
h1 {
font-size: var(--font-size-8);
margin-bottom: var(--size-2);
line-height: 1;
}
main {
overflow: auto;
overflow-x: hidden;
background: var(--surface-2);
padding: var(--size-4);
position: relative;
width: var(--size-content-3);
max-width: 100vw;
height: 100vh;
}
article {
width: 100%;
position: relative;
}
p {
max-inline-size: 100%;
}
header {
margin-bottom: var(--size-6);
}
article > p + p {
margin-top: var(--size-4);
}
a {
display: inline-block;
}
footer {
display: none;
position: fixed;
padding: var(--size-4);
background: var(--gray-0);
bottom: var(--size-2);
left: 50%;
font-size: var(--font-size-0);
transform: translateX(-50%);
box-shadow: var(--shadow-3);
border-radius: var(--radius-2);
}
[popover] {
position: absolute;
inset-inline-start: auto;
inset-inline-end: auto;
margin: 0;
padding: var(--size-4);
white-space: nowrap;
display: block;
min-width: 0;
max-width: 100%;
align-items: start;
z-index: 2;
justify-content: end;
box-shadow: var(--shadow-4);
}
}
// It's a lot of position-fallbacks but they all do the same thing!
const POPS = document.querySelectorAll("[popover]");
POPS.forEach((POP) => POP.showPopover());
Also see: Tab Triggers