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.
- for (var x = 0; x < 20; x++)
.box-wrap
.box
.img-wrap
img(src=`https://picsum.photos/800/300?test=${x}`, alt="")
h2 Card Title
.box-content
.actions
.action-one
| <svg viewBox="0 0 640 512" width="100" title="biking"><path d="M400 96a48 48 0 1 0-48-48 48 48 0 0 0 48 48zm-4 121a31.9 31.9 0 0 0 20 7h64a32 32 0 0 0 0-64h-52.78L356 103a31.94 31.94 0 0 0-40.81.68l-112 96a32 32 0 0 0 3.08 50.92L288 305.12V416a32 32 0 0 0 64 0V288a32 32 0 0 0-14.25-26.62l-41.36-27.57 58.25-49.92zm116 39a128 128 0 1 0 128 128 128 128 0 0 0-128-128zm0 192a64 64 0 1 1 64-64 64 64 0 0 1-64 64zM128 256a128 128 0 1 0 128 128 128 128 0 0 0-128-128zm0 192a64 64 0 1 1 64-64 64 64 0 0 1-64 64z" /></svg>
.action-two
| <svg viewBox="0 0 480 512" width="100" title="car-alt"><path d="M438.66 212.33l-11.24-28.1-19.93-49.83C390.38 91.63 349.57 64 303.5 64h-127c-46.06 0-86.88 27.63-103.99 70.4l-19.93 49.83-11.24 28.1C17.22 221.5 0 244.66 0 272v48c0 16.12 6.16 30.67 16 41.93V416c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32v-32h256v32c0 17.67 14.33 32 32 32h32c17.67 0 32-14.33 32-32v-54.07c9.84-11.25 16-25.8 16-41.93v-48c0-27.34-17.22-50.5-41.34-59.67zm-306.73-54.16c7.29-18.22 24.94-30.17 44.57-30.17h127c19.63 0 37.28 11.95 44.57 30.17L368 208H112l19.93-49.83zM80 319.8c-19.2 0-32-12.76-32-31.9S60.8 256 80 256s48 28.71 48 47.85-28.8 15.95-48 15.95zm320 0c-19.2 0-48 3.19-48-15.95S380.8 256 400 256s32 12.76 32 31.9-12.8 31.9-32 31.9z" /></svg>
.action-three
| <svg viewBox="0 0 320 512" width="100" title="walking"><path d="M208 96c26.5 0 48-21.5 48-48S234.5 0 208 0s-48 21.5-48 48 21.5 48 48 48zm94.5 149.1l-23.3-11.8-9.7-29.4c-14.7-44.6-55.7-75.8-102.2-75.9-36-.1-55.9 10.1-93.3 25.2-21.6 8.7-39.3 25.2-49.7 46.2L17.6 213c-7.8 15.8-1.5 35 14.2 42.9 15.6 7.9 34.6 1.5 42.5-14.3L81 228c3.5-7 9.3-12.5 16.5-15.4l26.8-10.8-15.2 60.7c-5.2 20.8.4 42.9 14.9 58.8l59.9 65.4c7.2 7.9 12.3 17.4 14.9 27.7l18.3 73.3c4.3 17.1 21.7 27.6 38.8 23.3 17.1-4.3 27.6-21.7 23.3-38.8l-22.2-89c-2.6-10.3-7.7-19.9-14.9-27.7l-45.5-49.7 17.2-68.7 5.5 16.5c5.3 16.1 16.7 29.4 31.7 37l23.3 11.8c15.6 7.9 34.6 1.5 42.5-14.3 7.7-15.7 1.4-35.1-14.3-43zM73.6 385.8c-3.2 8.1-8 15.4-14.2 21.5l-50 50.1c-12.5 12.5-12.5 32.8 0 45.3s32.7 12.5 45.2 0l59.4-59.4c6.1-6.1 10.9-13.4 14.2-21.5l13.5-33.8c-55.3-60.3-38.7-41.8-47.4-53.7l-20.7 51.5z" /></svg>
p Lorem, ipsum dolor sit amet consectetur adipisicing elit. Laborum tempore harum, facilis necessitatibus quia, omnis laudantium quas neque maiores minus porro veniam illum, fugiat ea id libero? Ipsum, illo? Ab!
.tags
a(href="#") One
a(href="#") Two
a(href="#") Three
html {
container: html / inline-size;
font-family: system-ui, sans-serif;
background-color: #13254a;
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100%25' height='100%25' viewBox='0 0 1600 900'%3E%3Cg fill='none' stroke-width='1' stroke-opacity='0.46' stroke-miterlimit='10'%3E%3Cpath stroke='%23FF0' d='M162-421.4c0 0 233.2 85.5 73.6 206.1c-76.7 58.4 62.2 169.8 12.2 245.9C206.8 93.2 90.9 27.4-77.3 13C-179.4 4.3-240 79.9-240 79.9'/%3E%3Cpath stroke='%23ffe600' d='M299-392.8c0 0 248.1 102.5 72.2 238.2c-91 70.2 82.1 187.5 18.5 274.8c-55.1 75.6-217.3-10-406.3-19.3C-148.2 94.6-216 195.8-216 195.8'/%3E%3Cpath stroke='%23ffcc00' d='M436-364.1c0 0 263.3 119.9 70.8 270.4c-105.3 82.3 101.8 205 24.7 303.7c-69.2 88.6-277.6-16-487.4-20.9C-116.9 185.3-192 311.7-192 311.7'/%3E%3Cpath stroke='%23ffb300' d='M573.1-335.5c0 0 278.6 137.4 69.4 302.5c-119.4 94.3 121.5 222.5 31 332.6c-83.4 101.5-337.9-21.7-568.6-22.5C-85.7 276.4-168 427.6-168 427.6'/%3E%3Cpath stroke='%23fe9b00' d='M710.1-306.9c0 0 293.8 154.8 68 334.6c-133.6 106.4 141.1 239.9 37.2 361.5c-97.6 114.4-398.2-27.1-649.7-24.2C-54.5 367.7-144 543.5-144 543.5'/%3E%3Cpath stroke='%23f6830d' d='M847.1-278.3c0 0 309.4 172.8 66.6 366.7c-147.6 118.7 160.6 257.3 43.5 390.4c-111.9 127.2-458.5-32.4-730.8-25.8C-23.2 459.1-120 659.5-120 659.5'/%3E%3Cpath stroke='%23ec6b1c' d='M984.1-249.7c0 0 324.7 190.3 65.2 398.8C887.6 280 1229.5 423.8 1099 568.5c-126.2 140-518.8-37.6-812-27.4C8.1 550.8-96 775.4-96 775.4'/%3E%3Cpath stroke='%23df5425' d='M1121.1-221c0 0 339.9 207.7 63.8 431c-175.9 142.8 199.7 292 56 448.3c-140.5 152.8-579-42.7-893.1-29.1C39.4 642.5-72 891.3-72 891.3'/%3E%3Cpath stroke='%23cf3c2c' d='M1258.1-192.4c0 0 355.1 225.2 62.4 463.1c-190.1 154.9 219 309 62.2 477.2c-155.2 165.3-639.3-47.7-974.3-30.7C70.7 734.3-48 1007.2-48 1007.2'/%3E%3Cpath stroke='%23bd2330' d='M1395.2-163.8c0 0 370.4 242.7 61 495.2c-204.3 167 238.6 326.5 68.5 506.1c-169.4 178.2-699.5-52.8-1055.4-32.3C102 826.3-24 1123.1-24 1123.1'/%3E%3Cpath stroke='%23aa0033' d='M1532.2-135.2c0 0 385.6 260.1 59.6 527.3c-218.4 179 258.3 343.9 74.7 535s-759.7-57.8-1136.5-34C133.3 918.2 0 1239 0 1239'/%3E%3C/g%3E%3C/svg%3E");
background-attachment: fixed;
background-size: cover;
}
body {
margin: 0;
padding: 6cqi;
display: grid;
place-items: center;
grid-template-columns: repeat(auto-fill, minmax(20cqi, 1fr));
align-items: end;
gap: 6cqi;
grid-auto-flow: dense;
}
.box-wrap {
width: 100%;
outline: 1cqi solid white;
border-radius: 2cqi;
background: white;
box-shadow: 0 1cqi 3cqi black;
container: box / inline-size;
&:nth-child(3) {
grid-column: span 2;
}
&:nth-child(7) {
grid-column: span 2;
}
&:nth-child(9) {
grid-column: span 2;
}
}
.box {
background: white;
border: 2cqi solid #c1d5ff;
font-size: calc(4cqi + 0.25rem);
line-height: 1.3;
border-radius: 8cqi;
overflow: clip;
.box-content {
padding: 8cqi;
display: grid;
gap: 2cqi;
@container (min-width: 300px) {
/* grid-template-columns: 10cqi 90cqi; */
grid-template-columns: 10% 90%;
}
}
.img-wrap {
background: linear-gradient(to bottom, #c1d5ff, black);
display: grid;
place-items: end start;
color: white;
> * {
grid-area: 1 / 1;
}
}
img {
mix-blend-mode: soft-light;
inline-size: 100%;
aspect-ratio: 2 / 1;
object-fit: cover;
display: block;
}
}
h2 {
font-size: calc(8cqi + 0.25rem);
margin: 0;
padding: 4cqi;
}
p {
margin: 0 0 4cqi 0;
}
.tags {
display: flex;
gap: 1.2cqi;
a {
text-decoration: none;
font-size: clamp(14px, 4cqi + 0.5rem, 24px);
background: oklch(67% 14% 251deg);
color: white;
border-radius: 1cqi;
padding: 1.2cqi 2cqi;
}
}
.actions {
padding: 2cqi;
container: actions / inline-size;
display: flex;
gap: 3cqi;
svg {
display: block;
width: 4cqmax;
min-width: 24px;
max-width: 100%;
aspect-ratio: 1;
background: #eee;
padding: 2cqi;
border-radius: 2cqi;
}
@container (min-width: 300px) {
flex-direction: column;
}
}
* {
box-sizing: border-box;
}
Also see: Tab Triggers