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="stars"></div>
<div class="shooting-star"></div>
<div class="shooting-star"></div>
<div class="shooting-star"></div>
<div class="shooting-star"></div>
<div class="shooting-star"></div>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
min-height: 100vh;
background: linear-gradient(to bottom, #0b0b2b, #1b2735 70%, #090a0f);
overflow: hidden;
}
.stars {
width: 1px;
height: 1px;
position: absolute;
background: white;
box-shadow: 2vw 5vh 2px white, 10vw 8vh 2px white, 15vw 15vh 1px white,
22vw 22vh 1px white, 28vw 12vh 2px white, 32vw 32vh 1px white,
38vw 18vh 2px white, 42vw 35vh 1px white, 48vw 25vh 2px white,
53vw 42vh 1px white, 58vw 15vh 2px white, 63vw 38vh 1px white,
68vw 28vh 2px white, 73vw 45vh 1px white, 78vw 32vh 2px white,
83vw 48vh 1px white, 88vw 20vh 2px white, 93vw 52vh 1px white,
98vw 35vh 2px white, 5vw 60vh 1px white, 12vw 65vh 2px white,
18vw 72vh 1px white, 25vw 78vh 2px white, 30vw 85vh 1px white,
35vw 68vh 2px white, 40vw 82vh 1px white, 45vw 92vh 2px white,
50vw 75vh 1px white, 55vw 88vh 2px white, 60vw 95vh 1px white,
65vw 72vh 2px white, 70vw 85vh 1px white, 75vw 78vh 2px white,
80vw 92vh 1px white, 85vw 82vh 2px white, 90vw 88vh 1px white,
95vw 75vh 2px white;
animation: twinkle 8s infinite linear;
}
.shooting-star {
position: absolute;
width: 100px;
height: 2px;
background: linear-gradient(90deg, white, transparent);
animation: shoot 3s infinite ease-in;
}
.shooting-star:nth-child(1) {
top: 20%;
left: -100px;
animation-delay: 0s;
}
.shooting-star:nth-child(2) {
top: 35%;
left: -100px;
animation-delay: 1s;
}
.shooting-star:nth-child(3) {
top: 50%;
left: -100px;
animation-delay: 2s;
}
@keyframes twinkle {
0%,
100% {
opacity: 0.8;
}
50% {
opacity: 0.4;
}
}
@keyframes shoot {
0% {
transform: translateX(0) translateY(0) rotate(25deg);
opacity: 1;
}
100% {
transform: translateX(120vw) translateY(50vh) rotate(25deg);
opacity: 0;
}
}
/* Additional twinkling stars with different animation timing */
.stars::after {
content: "";
position: absolute;
width: 1px;
height: 1px;
background: white;
box-shadow: 8vw 12vh 2px white, 16vw 18vh 1px white, 24vw 25vh 2px white,
33vw 15vh 1px white, 41vw 28vh 2px white, 49vw 35vh 1px white,
57vw 22vh 2px white, 65vw 42vh 1px white, 73vw 28vh 2px white,
81vw 48vh 1px white, 89vw 32vh 2px white, 97vw 45vh 1px white,
3vw 68vh 2px white, 11vw 75vh 1px white, 19vw 82vh 2px white,
27vw 88vh 1px white, 35vw 72vh 2px white, 43vw 85vh 1px white,
51vw 92vh 2px white, 59vw 78vh 1px white;
animation: twinkle 6s infinite linear reverse;
}
Also see: Tab Triggers