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.
<header>
<img src="https://picsum.photos/400/400?random=1" alt="" width="400" height="400" />
<h1>
<span aria-hidden="true">Some</span>
<span aria-hidde="true">fancy</span>
<span aria-hidden="true">website</span>
<span class="sr-only">Some fancy website</span>
</h1>
</header>
<main>
<section>
<img src="https://picsum.photos/400/400?random=1" alt="" width="200" height="200">
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Harum consequuntur accusamus quaerat corrupti quam consequatur modi saepe vitae, obcaecati veritatis dolorum officia itaque inventore illum quae sint minus totam magnam!</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=2" alt="" width="200" height="200">
<p>Aut veritatis perspiciatis nulla natus, possimus laborum nam perferendis magni debitis id accusantium consequuntur laboriosam reprehenderit voluptas vel magnam error. Pariatur sit amet, aliquid illo quas alias reprehenderit quibusdam velit.</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=3" alt="" width="200" height="200">
<p>Necessitatibus ipsa iste consectetur provident in blanditiis sapiente consequuntur! Sit omnis odit nihil quam totam voluptates laudantium quis. Quo recusandae voluptatibus ipsa accusantium modi neque molestias, magnam facilis unde. Dolores!</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=4" alt="" width="200" height="200">
<p>Eum numquam odit, quaerat repellendus quidem asperiores, itaque officiis quam sequi, temporibus dolorum. Molestias, accusamus aspernatur officia placeat natus fugit, iusto voluptas omnis porro exercitationem, distinctio sit reiciendis tempora vitae?</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=5" alt="" width="200" height="200">
<p>Animi aliquid reiciendis voluptates velit dolor debitis ipsum quam odio vitae? Eligendi facilis nobis voluptate tenetur incidunt qui laudantium animi totam suscipit est veniam obcaecati nam hic, mollitia quis nisi.</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=6" alt="" width="200" height="200">
<p>Blanditiis recusandae, unde voluptate minus reprehenderit dignissimos nesciunt sint fugit tempora alias doloremque consequatur beatae numquam possimus ex perferendis non quod, eaque nobis laboriosam officiis. A in inventore consectetur voluptates.</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=7" alt="" width="200" height="200">
<p>Quod quam dolorem debitis esse libero aut, aliquid repellendus. Totam, facere? Molestias dignissimos numquam adipisci voluptates voluptatum eos error explicabo itaque quod quam? Eum omnis ipsum commodi, eaque veniam vel?</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=8" alt="" width="200" height="200">
<p>Nemo, dignissimos officiis, ipsum nulla suscipit aperiam ratione dicta quos sapiente sed at molestiae. Autem tempora iure dignissimos veritatis velit cumque, delectus rerum, dicta nobis accusantium veniam nostrum nulla consequatur.</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=9" alt="" width="200" height="200">
<p>Neque, ipsum, at illo harum ut cupiditate adipisci unde quis, illum veniam laboriosam. Quasi adipisci nemo perferendis eligendi beatae sunt earum quaerat, soluta odit perspiciatis quibusdam recusandae? Quia, dolorum. Quas.</p>
</section>
<section>
<img src="https://picsum.photos/400/400?random=10" alt="" width="200" height="200">
<p>Quod praesentium natus ullam recusandae soluta quidem aliquid? Accusamus aspernatur sed odit a est quisquam repellat nihil nobis, placeat maxime. Cum maiores minus vero facilis dolorem sit ab dolores eius?</p>
</section>
</main>
<footer>Thanks for stopping by! 👋</footer>
<div class="ring-wrapper">
<div class="ring" style="--char-count:18; --font-size:1.5; --character-width:1; --radius:calc( (1 / 0.324699) * -1ch );"><span aria-hidden="true" class="char" style="--char-index: 0;">S</span><span aria-hidden="true" class="char" style="--char-index: 1;">c</span><span aria-hidden="true" class="char" style="--char-index: 2;">r</span><span aria-hidden="true" class="char" style="--char-index: 3;">o</span><span aria-hidden="true" class="char" style="--char-index: 4;">l</span><span aria-hidden="true" class="char" style="--char-index: 5;">l</span><span aria-hidden="true" class="char" style="--char-index: 6;"> </span><span aria-hidden="true" class="char" style="--char-index: 7;">•</span><span aria-hidden="true" class="char" style="--char-index: 8;"> </span><span aria-hidden="true" class="char" style="--char-index: 9;">S</span><span aria-hidden="true" class="char" style="--char-index: 10;">c</span><span aria-hidden="true" class="char" style="--char-index: 11;">r</span><span aria-hidden="true" class="char" style="--char-index: 12;">o</span><span aria-hidden="true" class="char" style="--char-index: 13;">l</span><span aria-hidden="true" class="char" style="--char-index: 14;">l</span><span aria-hidden="true" class="char" style="--char-index: 15;"> </span><span aria-hidden="true" class="char" style="--char-index: 16;">•</span><span aria-hidden="true" class="char" style="--char-index: 17;"> </span><span class="sr-only">Scroll • Scroll • </span></h>
</div>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@900&display=swap');
@import "https://unpkg.com/normalize.css";
@import "https://unpkg.com/open-props/normalize.min.css";
@import "https://unpkg.com/open-props/open-props.min.css";
*,
*:after,
*:before {
box-sizing: border-box;
}
body {
min-height: 100vh;
font-family: 'Inter', sans-serif, system-ui;
background: var(--surface-2);
display: grid;
justify-items: center;
align-content: start;
overflow-x: hidden;
}
:root {
--content: 66ch;
--gutter: 1rem;
--gap: 0rem;
}
header, main {
width: var(--content);
max-width: calc(100vw - (2 * var(--gutter)));
margin: 0 auto;
}
footer {
padding: 2rem;
font-size: 0.875rem;
}
header {
min-height: 100vh;
display: grid;
align-content: center;
}
h1 {
font-weight: 900;
font-family: impact;
font-size: calc(var(--font-size-fluid-3) * 2.5);
line-height: 1;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
header {
position: relative;
}
header img {
position: absolute;
left: 25%;
top: 15%;
z-index: 1;
opacity: 0.65;
filter: saturate(0.5);
clip-path: polygon(0 15%, 75% 0, 100% 32%, 80% 100%, 0 67%);
}
h1 {
z-index: 2;
position: relative;
}
h1 span:nth-of-type(2) {
color: transparent;
-webkit-text-stroke: 0.25rem var(--text-1);
}
section {
display: grid;
gap: var(--gutter);
grid-template-columns:
auto
1fr;
align-items: center;
min-height: 100vh;
}
p:first-line {
text-transform: uppercase;
font-weight: bold;
}
section p {
z-index: 2;
background: hsl(210 17% 98% / 0.65);
padding: 1rem;
color: var(--text-1);
backdrop-filter: blur(4px);
font-size: 1rem;
}
@media(prefers-color-scheme: dark) {
section p {
background: hsl(210 11% 15% / 0.65);
}
}
section img {
grid-column: 1;
width: 260px;
max-width: 20vw;
clip-path: polygon(0 10%, 10% 0, 100% 0, 100% 90%, 90% 100%, 0 100%);
scale: 1.5;
}
section:nth-of-type(even) {
grid-template-columns:
1fr
auto;
grid-auto-flow: dense;
}
section:nth-of-type(even) img {
grid-column: 2;
}
section:nth-of-type(even) p {
grid-column: 1;
}
section {
--x: -100%;
}
section:nth-of-type(even) {
--x: 100%;
}
section img {
view-timeline: --item;
animation: item-reveal both ease-in;
animation-timeline: --item;
animation-delay: cover 10%;
animation-end-delay: cover 35%;
animation-range: cover 10% cover 35%;
}
section img {
--y: 0;
}
section p {
--x: 0;
--y: 50%;
view-timeline: --item;
animation: item-reveal both ease-out;
animation-timeline: --item;
animation-delay: cover 35%;
animation-end-delay: cover 50%;
animation-range: cover 35% cover 50%;
position: sticky;
bottom: 40%;
}
@keyframes item-reveal {
0% {
opacity: 0;
translate: var(--x, 0) var(--y, 0);
}
}
.ring-wrapper {
--char-count: 19;
--inner-angle: calc((360 / var(--char-count, 19)) * 1deg);
--character-width: 1.0;
--radius: calc((var(--character-width, 1.0) / 0.32469946920468346) * -1ch);
--font-size: 1.5rem;
position: fixed;
top: 0;
right: 0;
height: calc((var(--character-width, 1.0) / 0.32469946920468346) * 3.5ch);
width: calc((var(--character-width, 1.0) / 0.32469946920468346) * 3.5ch);
translate: 0% 0%;
display: grid;
place-items: center;
z-index: 10;
border: calc(var(--character-width) * 2rem) solid var(--surface-2);
border-radius: 50%;
font-weight: bold;
}
.ring {
font-family: monospace;
text-transform: uppercase;
font-size: calc(var(--font-size, 1) * 1rem);
animation: rotation 6s both linear;
position: relative;
animation-timeline: scroll(root);
}
.char {
display: inline-block;
position: absolute;
top: 50%;
left: 50%;
transform:
translate(-50%, -50%)
rotate(calc(var(--inner-angle) * var(--char-index)))
translateY(var(--radius));
}
@keyframes rotation {
to {
rotate: 720deg;
}
}
Also see: Tab Triggers