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.
<ol>
<li>A partridge in a pear tree</li>
<li>Two turtle doves</li>
<li>Three french hens</li>
<li>Four calling birds</li>
<li>Five golden rings</li>
<li>Six geese-a-laying</li>
<li>Seven swans a-swimming</li>
<li>Eight maids a-milking</li>
<li>Nine ladies dancing</li>
<li>Ten lords a-leaping</li>
<li>Eleven pipers piping</li>
<li>Twelve drummers drumming</li>
</ol>
<!-- svg describing a cursor to suggest scrolling -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-1 -1 22 32" width="44" height="64">
<g fill="none" stroke-width="2" stroke="currentColor">
<!-- describe the offset through a custom property to animate the path to that value (its opposite since it's more entertaining) -->
<path style="--offset: -5;" id="offset" d="M 10 8 v 5" stroke-linecap="round" stroke-dasharray="5" stroke-dashoffset="5" />
<rect width="20" height="30" rx="10" />
</g>
</svg>
@import url("https://fonts.googleapis.com/css?family=Major+Mono+Display|Neuton&display=swap");
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
min-height: 100vh;
color: hsl(0, 0%, 100%);
font-family: "Neuton", serif;
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' opacity='0.1' viewBox='-100 -100 200 200' width='100' height='100'%3E%3Cg id='snowflake'%3E%3Cg opacity='0.5' fill='hsl(0, 0%25, 100%25)'%3E%3Ccircle cx='-35' cy='-25' r='3.5' /%3E%3Ccircle cx='30' cy='-40' r='2' /%3E%3Ccircle cx='-15' cy='35' r='2.5' /%3E%3Ccircle cx='25' cy='10' r='2' /%3E%3Crect transform='rotate(45)' x='-10' y='-10' width='20' height='20'/%3E%3Cpath d='M -20 0 a 12 12 0 0 1 -12 -12 12 12 0 0 1 -12 12 12 12 0 0 1 12 12 12 12 0 0 1 12 -12' /%3E%3Cpath transform='rotate(90)' d='M -20 0 a 12 12 0 0 1 -12 -12 12 12 0 0 1 -12 12 12 12 0 0 1 12 12 12 12 0 0 1 12 -12' /%3E%3Cpath transform='rotate(180)' d='M -20 0 a 12 12 0 0 1 -12 -12 12 12 0 0 1 -12 12 12 12 0 0 1 12 12 12 12 0 0 1 12 -12' /%3E%3Cpath transform='rotate(270)' d='M -20 0 a 12 12 0 0 1 -12 -12 12 12 0 0 1 -12 12 12 12 0 0 1 12 12 12 12 0 0 1 12 -12' /%3E%3C/g%3E%3Cg fill='none' stroke-width='2' stroke='hsl(0, 0%25, 100%25)'%3E%3Cpath d='M -30 0 h 60 m -30 -30 v 60' /%3E%3Cpath transform='rotate(45)' d='M -30 0 h 60 m -30 -30 v 60' /%3E%3C/g%3E%3C/g%3E%3Cuse href='%23snowflake' x='100' y='100' /%3E%3Cuse href='%23snowflake' x='100' y='-100' /%3E%3Cuse href='%23snowflake' x='-100' y='100' /%3E%3Cuse href='%23snowflake' x='-100' y='-100' /%3E%3C/svg%3E"),
linear-gradient(to bottom left, hsl(0, 85%, 50%), hsl(0, 90%, 40%));
background-size: 120px, 100%;
/* center the elements horizontally */
display: flex;
flex-direction: column;
align-items: center;
}
/* display the cursor-svg in the top left corner */
svg {
position: fixed;
bottom: 1rem;
left: 1rem;
width: 30px;
height: auto;
display: block;
}
/* animate the cursor-svg to fade out after the path element has been animated enough times to be annoying */
svg {
animation: fadeOut 0.5s 10s forwards;
#offset {
animation: removeOffset 2s 5 ease-in-out;
}
}
@keyframes removeOffset {
37.5% {
stroke-dashoffset: 0;
}
75% {
stroke-dashoffset: var(--offset);
}
}
@keyframes fadeOut {
to {
opacity: 0;
}
}
/* replace the default list-style with a custom counter */
ol {
list-style: none;
counter-reset: days-counter;
font-size: 2rem;
position: relative;
}
/* increment the custom counter */
ol li {
counter-increment: days-counter;
/* center the content in the viewport */
height: 100vh;
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: center;
text-shadow: 0 1px 5px hsla(0, 0%, 0%, 0.8);
/* position relative to absolute position the pseudo element behind the text */
z-index: 5;
}
/* display the custom counter with the :before pseudo element, in the very center of the list item */
ol li:before {
content: counter(days-counter);
z-index: -5;
position: absolute;
opacity: 0.5;
font-size: 15vh;
font-family: "Major Mono Display", monospace;
transform: translate(-50%, 0%);
}
/* added bonus, a more christmas-y selection */
ol li::selection {
color: hsl(0, 0%, 100%);
background: hsl(130, 50%, 35%);
}
/* position the custom counter to the left/right for odd/even list items */
ol li:nth-child(odd):before {
left: 0%;
}
ol li:nth-child(even):before {
left: 100%;
}
/* add position sticky and position each subsequent list item 7.5vh from the previous */
ol li {
position: sticky;
}
/* ! have the list items occupy enough vertical space to cover (viewport - vertical offset)
otherwise the elements would collapse to the top once the page reaches the last item
*/
@for $counter from 1 through 12 {
ol li:nth-child(#{$counter}) {
top: #{($counter - 1) * 7.5vh};
height: #{100vh - ($counter - 1) * 7.5vh};
}
}
Also see: Tab Triggers