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 role="img" aria-label="Cartoon of a chameleon resting on a branch"></div>
div {
width: 60vmin;
height: 60vmin;
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
overflow: auto;
background-image:
linear-gradient(176deg, indianred 80%, transparent 0),
radial-gradient(at 100% 50%, #090 50%, transparent 0),
radial-gradient(at 0% 50%, #0a0 50%, transparent 0),
radial-gradient(farthest-side at 100% 100%, transparent calc(99.9% - 6vmin), indianred 0 99.9%, transparent 0),
linear-gradient(transparent 80%, darksalmon 0, salmon 90%, #59361A 0, transparent 120%)
;
background-size:
40vmin 10vmin,
4vmin 18vmin,
3vmin 18vmin,
60vmin 100vmin,
100% 100%
;
background-position:
calc(50% - 15vmin) calc(50% + 5vmin),
calc(50% - 5vmin) calc(50% + 14vmin),
calc(50% - 2vmin) calc(50% + 14vmin),
calc(50% - 64.75vmin) calc(50% + 50vmin),
0 0
;
background-repeat: no-repeat;
}
div::before {
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 400%;
height: 100%;
background-color: #fec;
filter: blur(1vmin);
background-image:
/* lamp */
conic-gradient(at 50% -150%, transparent 160deg, #fff 0 200deg, transparent 0),
radial-gradient(at 50% 80vh, aqua 40%, transparent 0),
/* ball */
radial-gradient(circle closest-side, #36f, #14d 80% 99.9%, transparent 0),
/* bottle */
linear-gradient(#5007, #5007),
radial-gradient(ellipse 120% 100% at 50% 100%, #0a0 80%, transparent 0),
linear-gradient(#080, #080),
linear-gradient(#0a0, #0a0),
radial-gradient(farthest-side at 50% 55%, salmon 99.9%, transparent 0),
linear-gradient(rgb(230, 108, 100), salmon)
/* wall paper */
,
repeating-linear-gradient(45deg, transparent 0 calc(5vmin - 0.5px), #d0c0a055 0 calc(5vmin + 0.5px), transparent 0 10vmin),
repeating-linear-gradient(-45deg, transparent 0 calc(5vmin - 0.5px), #d0c0a055 0 calc(5vmin + 0.5px), transparent 0 10vmin)
;
background-size:
/* lamp */
100vw 30vh,
50vmin 80vh,
/* ball */
100vw 60vh,
/* bottle */
28vmin 39vh,
30vmin 70vh,
10vmin 4vh,
8vmin 30vh,
10vmin 4.5vh,
6vmin 3.5vh
,
100% 100%,
100% 100%
;
background-position:
/* lamp */
200vw 15vh,
calc(250vw - 25vmin) 0,
/* ball */
300vw 20vh,
/* bottle */
calc(150vw - 14vmin) 40vh,
calc(150vw - 15vmin) 10vh,
calc(150vw - 5vmin) 15vh,
calc(150vw - 4vmin) 15vh,
calc(150vw - 5vmin) 9.5vh,
calc(150vw - 3vmin) 14vh
,
0 0,
0 0
;
background-repeat: no-repeat;
z-index: -2;
}
@property --x {
syntax: '<length>';
inherits: false;
initial-value: 7vmin;
}
@property --y {
syntax: '<length>';
inherits: false;
initial-value: 7vmin;
}
@keyframes moveEye {
0%, 100% { --x: 7vmin; --y: 21vmin; }
20% { --x: 7vmin; --y: 21vmin; }
40% { --x: 10vmin; --y: 25vmin; }
60% { --x: 9vmin; --y: 22vmin; }
80% { --x: 8vmin; --y: 24vmin; }
}
div::after {
animation: moveEye 10s infinite;
--x: 7vmin;
--y: 21vmin;
content: "";
display: block;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) skew(-2deg);
width: 70vmin;
height: 70vmin;
aopacity: 0.5;
mix-blend-mode: multiply;
backdrop-filter: opacity(0.5) blur(0.5vmin);
pointer-events: none;
background-image:
/* eye */
radial-gradient(black 60%, transparent 0),
radial-gradient(#de3 0%, transparent 90%),
radial-gradient(greenyellow 60%, transparent 0),
/* head */
radial-gradient(farthest-side at 50% 100%, transparent 99.99%, transparent 0),
radial-gradient(farthest-side at 100% 100%, lime 99.99%, transparent 0),
/* body */
radial-gradient(farthest-side at 0% 50%, lime 99.99%, transparent 0),
radial-gradient(farthest-side at 100% 50%, lime 99.99%, transparent 0),
radial-gradient(farthest-side at 0% 50%, greenyellow 99.99%, transparent 0),
radial-gradient(farthest-side at 100% 50%, greenyellow 99.99%, transparent 0),
radial-gradient(farthest-side at 100% 100%, greenyellow 99.99%, transparent 0),
radial-gradient(farthest-side at 0% 50%, lime 99.99%, transparent 0)
;
background-size:
/* eye */
1.5vmin 1.5vmin,
3vmin 3vmin,
10vmin 10vmin,
/* head */
50vmin 0.5vmin,
23vmin 22vmin,
/* body */
2.5vmin 5vmin,
4vmin 8vmin,
6vmin 12vmin,
10vmin 20vmin,
40.25vmin 20vmin,
20vmin 40vmin
;
background-position:
/* eye */
var(--x) var(--y),
calc(var(--x) - 0.75vmin) calc(var(--y) - 0.75vmin),
5vmin 18vmin,
/* head */
0 34.5vmin,
0 13vmin,
/* body */
50vmin 39vmin,
46.125vmin 39vmin,
50vmin 35vmin,
40.125vmin 35vmin,
10vmin 15vmin,
50vmin 15vmin
;
background-repeat: no-repeat;
z-index: -1;
}
Also see: Tab Triggers