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>
<h1 id="brand-name">LikeNuShus</h1>
<p class="tagline">Lightly Used Shoes, Cheap!</p>
<svg viewBox="0 0 640 512" width="100" title="shoe-logo" id="logo">
<path d="M192 160h32V32h-32c-35.35 0-64 28.65-64 64s28.65 64 64 64zM0 416c0 35.35 28.65 64 64 64h32V352H64c-35.35 0-64 28.65-64 64zm337.46-128c-34.91 0-76.16 13.12-104.73 32-24.79 16.38-44.52 32-104.73 32v128l57.53 15.97c26.21 7.28 53.01 13.12 80.31 15.05 32.69 2.31 65.6.67 97.58-6.2C472.9 481.3 512 429.22 512 384c0-64-84.18-96-174.54-96zM491.42 7.19C459.44.32 426.53-1.33 393.84.99c-27.3 1.93-54.1 7.77-80.31 15.04L256 32v128c60.2 0 79.94 15.62 104.73 32 28.57 18.88 69.82 32 104.73 32C555.82 224 640 192 640 128c0-45.22-39.1-97.3-148.58-120.81z" />
</svg>
</header>
<h2>Clearance Items</h2>
<p class="category-description">Gently used floor model sneakers and discontinued styles at our lowest prices of the year. Get 'em before they're gone!</p>
<div class="item" tabindex="0">
<h3>Asics</h3>
<figure>
<img src="https://source.unsplash.com/jZyacqaR4iI" alt="a pair of blue and red ASICS sneakers">
<figcaption>Photo by Maksim Larin</figcaption>
</figure>
<p class="description">
Suede fabric pointed toe stylish cut front low heel sharp on-trend toe point raised heel drop sides unique silhouette. Bow detail metallic eyelets leather lining luxurious finish classic courts formal slingback square toe contrasting cap. Lace up fastening bow detailing high stiletto heel leather lining beautiful lace upper elegant peep toe t-bar strap. Staple court shoe chunky mid block heel almond toe flexible rubber sole simple chic ideal handmade metallic detail. Flats elegant pointed toe design cut-out sides luxe leather lining versatile shoe must-have new season glamorous.</p>
<p class="price">$65 USD</p>
<p class="special">Free Shipping!</p>
<div class="options size-select">
<strong>Size:</strong>
<div>
<input type="radio" id="asics_size_6" name="asics_size" value="6">
<label for="asics_size_6">6</label>
<input type="radio" id="asics_size_6-5" name="asics_size" value="6.5">
<label for="asics_size_6-5">6.5</label>
<input type="radio" id="asics_size_7" name="asics_size" value="7" disabled>
<label for="asics_size_7">7</label>
<input type="radio" id="asics_size_7-5" name="asics_size" value="7.5">
<label for="asics_size_7-5">7.5</label>
<input type="radio" id="asics_size_8" name="asics_size" value="8">
<label for="asics_size_8">8</label>
<input type="radio" id="asics_size_9" name="asics_size" value="9">
<label for="asics_size_9">9</label>
<input type="radio" id="asics_size_9-5" name="asics_size" value="9.5" disabled>
<label for="asics_size_9-5">9.5</label>
<input type="radio" id="asics_size_10" name="asics_size" value="10">
<label for="asics_size_10">10</label>
</div>
</div>
<div class="options color-select">
<strong>Color:</strong>
<div>
<input type="radio" id="asics_color_blue" name="asics_color" value="blue">
<label for="asics_color_blue">blue</label>
<input type="radio" id="asics_color_red" name="asics_color" value="red">
<label for="asics_color_red">red</label>
<input type="radio" id="asics_color_black" name="asics_color" value="black">
<label for="asics_color_black">black</label>
</div>
</div>
<div class="options quantity-select">
<label for="quantity-select">
<strong>Quantity:</strong>
</label>
<select name="quantity" id="quantity-select">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<button type="button">Add to Cart</button>
</div>
<div class="item" tabindex="0">
<h3>Adidas</h3>
<figure>
<img src="https://source.unsplash.com/JM-qKEd1GMI" alt="a pair of white Adidas sneakers with red and blue trim">
<figcaption>Photo by Daniel Storek</figcaption>
</figure>
<p class="description">
Effortless comfortable full leather lining eye-catching unique detail to the toe low 'cut-away' sides clean and sleek. Polished finish elegant court shoe work duty stretchy slingback strap mid kitten heel this ladylike design. Suede fabric pointed toe stylish cut front low heel sharp on-trend toe point raised heel drop sides unique silhouette. Effortless comfortable full leather lining eye-catching unique detail to the toe low 'cut-away' sides clean and sleek.</p>
<p class="price">$30 USD</p>
<div class="options size-select">
<strong>Size:</strong>
<div>
<input type="radio" id="adidas_size_6" name="adidas_size" value="6">
<label for="adidas_size_6">6</label>
<input type="radio" id="adidas_size_6-5" name="adidas_size" value="6.5" disabled>
<label for="adidas_size_6-5">6.5</label>
<input type="radio" id="adidas_size_7" name="adidas_size" value="7">
<label for="adidas_size_7">7</label>
<input type="radio" id="adidas_size_7-5" name="adidas_size" value="7.5">
<label for="adidas_size_7-5">7.5</label>
<input type="radio" id="adidas_size_8" name="adidas_size" value="8">
<label for="adidas_size_8">8</label>
<input type="radio" id="adidas_size_9" name="adidas_size" value="9">
<label for="adidas_size_9">9</label>
<input type="radio" id="adidas_size_9-5" name="adidas_size" value="9.5" disabled>
<label for="adidas_size_9-5">9.5</label>
<input type="radio" id="adidas_size_10" name="adidas_size" value="10" disabled>
<label for="adidas_size_10">10</label>
</div>
</div>
<div class="options color-select">
<strong>Color:</strong>
<div>
<input type="radio" id="adidas_color_olive" name="adidas_color" value="olive">
<label for="adidas_color_olive">olive & black</label>
<input type="radio" id="adidas_color_blue" name="adidas_color" value="blue">
<label for="adidas_color_blue">blue & black</label>
<input type="radio" id="adidas_color_pink" name="adidas_color" value="pink">
<label for="adidas_color_pink">pink & black</label>
</div>
</div>
<div class="options quantity-select">
<label for="quantity-select">
<strong>Quantity:</strong>
</label>
<select name="quantity" id="quantity-select">
<option value=""></option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div>
<button type="button">Add to Cart</button>
</div>
<div class="item" tabindex="0">
<h3>New Balance</h3>
<figure>
<img src="https://source.unsplash.com/6zO5VKogoZE" alt="a New Balance sneaker in olive drab with a black logo">
<figcaption>Photo by felipepelaquim</figcaption>
</figure>
<p class="description">
Suede fabric pointed toe stylish cut front low heel sharp on-trend toe point raised heel drop sides unique silhouette. Bow detail metallic eyelets leather lining luxurious finish classic courts formal slingback square toe contrasting cap. Lace up fastening bow detailing high stiletto heel leather lining beautiful lace upper elegant peep toe t-bar strap. Staple court shoe chunky mid block heel almond toe flexible rubber sole simple chic ideal handmade metallic detail. Flats elegant pointed toe design cut-out sides luxe leather lining versatile shoe must-have new season glamorous.</p>
<p class="price">$45 USD</p>
<p class="special">Just One Left!</p>
<div class="options size-select">
<strong>Size:</strong>
<div>
<input type="radio" id="new-balance_size_6" name="new-balance_size" value="6" checked>
<label for="new-balance_size_6">6</label>
<input type="radio" id="new-balance_size_6-5" name="new-balance_size" value="6.5" disabled>
<label for="new-balance_size_6-5">6.5</label>
<input type="radio" id="new-balance_size_7" name="new-balance_size" value="7" disabled>
<label for="new-balance_size_7">7</label>
<input type="radio" id="new-balance_size_7-5" name="new-balance_size" value="7.5" disabled>
<label for="new-balance_size_7-5">7.5</label>
<input type="radio" id="new-balance_size_8" name="new-balance_size" value="8" disabled>
<label for="new-balance_size_8">8</label>
<input type="radio" id="new-balance_size_9" name="new-balance_size" value="9" disabled>
<label for="new-balance_size_9">9</label>
<input type="radio" id="new-balance_size_9-5" name="new-balance_size" value="9.5" disabled>
<label for="new-balance_size_9-5">9.5</label>
<input type="radio" id="new-balance_size_10" name="new-balance_size" value="10" disabled>
<label for="new-balance_size_10">10</label>
</div>
</div>
<div class="options color-select">
<strong>Color:</strong>
<div>
<input type="radio" id="new-balance_color_red-blue" name="new-balance_color" value="red-blue" checked>
<label for="new-balance_color_red-blue">white with red and blue trim</label>
<input type="radio" id="new-balance_color_black" name="new-balance_color" value="black" disabled>
<label for="new-balance_color_black">white with black trim</label>
</div>
</div>
<div class="options quantity-select">
<strong>Quantity:</strong>
<div class="quantity">1</div>
</div>
<button type="button">Add to Cart</button>
</div>
@import url("https://use.typekit.net/hbf6obz.css");
:root {
--color1: #E9F2F1;
--color2: #dcff00;
--color3: #b3f700;
--color4: #00c41f;
--logo-size: 3rem;
--fanta: fantabular-sans-mvb, mono;
--border: 3px;
--h3-length: 5ch;
--h3-offset: 2ch;
--outline-color: #000;
--outline:
-1px -1px var(--outline-color),
-1px 0 var(--outline-color),
-1px 1px var(--outline-color),
0 -1px var(--outline-color),
0 0 var(--outline-color),
0 1px var(--outline-color),
1px -1px var(--outline-color),
1px 0 var(--outline-color),
1px 1px var(--outline-color)
;
}
html,
body {
overflow-x: hidden;
}
html {
background: var(--color1);
}
body {
box-sizing: border-box;
font-family: var(--fanta);
display: grid;
gap: 2rem;
grid-template-columns: repeat(3, 1fr);
margin: 0 auto;
max-width: 100rem;
padding: 0 2rem 2rem;
}
header {
align-items: center;
display: grid;
font-style: italic;
grid-column: span 3;
grid-template-columns: var(--logo-size) 1fr 1fr;
margin-bottom: 5rem;
padding: 0.5rem 1rem;
}
#brand-name {
margin: 0;
}
#logo {
grid-column: 1;
grid-row: 1;
height: var(--logo-size);
place-items: center;
width: calc(var(--logo-size) * 0.8);
}
#logo path {
transform: rotate(-45deg);
transform-origin: center;
}
.tagline {
text-align: right;
}
h2 {
--bg: var(--color2);
--color: #000;
--w: 18ch;
animation: marquee 8s linear infinite;
background: var(--bg) linear-gradient(45deg, var(--bg) 67%, var(--color3)) fixed;
box-shadow:
calc(var(--w) * -1) 0 var(--bg),
calc(var(--w) * -1) var(--border) ,
calc(var(--w) * -1) calc(var(--border) * -1) ,
0 calc(var(--border) * -1) ,
0 var(--border)
;
color: var(--color);
font-size: 2rem;
font-weight: 400;
left: 0;
margin: 0;
padding: 0.5rem 0;
position: absolute;
text-align: center;
text-shadow:
var(--w) 0 0,
calc(var(--w) * -1) 0 0,
calc(var(--w) * 2) 0 0,
calc(var(--w) * -2) 0 0,
calc(var(--w) * 3) 0 0,
calc(var(--w) * -3) 0 0,
calc(var(--w) * -4) 0 0
;
top: 5rem;
white-space: nowrap;
width: 100%;
}
h2::after {
content: " ✦";
}
@keyframes marquee {
from {
left: var(--w);
}
}
.category-description {
background-color: #fff;
border: var(--border) solid;
box-shadow:
1rem 1rem 0 var(--color4),
1rem 1rem 0 1px #000,
-1rem -1rem 0 var(--color3),
-1rem -1rem 0 1px #000
;
font-size: 1.25rem;
grid-column: span 3;
line-height: 1.5;
margin: 0 auto 1rem;
max-width: 50rem;
padding: 1em;
text-align: center;
}
button {
background: var(--color4) radial-gradient(circle, var(--color2), transparent) center;
background-size: 100% 100%;
border: 1px solid;
font: 1.5rem var(--fanta);
margin-top: 1rem;
padding: 0.5rem;
transition: background-size 250ms;
}
button:hover {
background-size: 200% 200%;
}
img {
aspect-ratio: 2 / 1;
display: block;
height: 100%;
object-fit: cover;
width: 100%;
}
figure {
aspect-ratio: 2 / 1;
margin: 0;
}
figcaption {
bottom: 0;
color: var(--color2);
font-style: italic;
position: absolute;
text-indent: 0.5ch;
text-shadow: var(--outline);
}
p + .item + .item figcaption {
color: #000;
text-shadow: none;
}
select {
border: 1px solid;
font: 1rem var(--fanta);
outline: none;
padding: 0.5rem;
width: 8ch;
}
.item {
display: flex;
flex-direction: column;
position: relative;
margin: 0 auto;
outline: none;
}
.item h3 {
color: var(--color3);
font-size: 2rem;
font-weight: 500;
left: 0;
margin: 0;
position: absolute;
right: 0;
text-align: center;
text-shadow: var(--outline);
text-transform: uppercase;
z-index: 10;
}
.item:focus-within {
background-color: #fff;
border: var(--border) solid;
box-sizing: border-box;
display: grid;
grid-column: 1 / span 2;
grid-row: 3 / span 3;
grid-template-columns: 1fr;
margin: 0;
padding: 1rem;
padding-top: 2rem;
}
.item:focus-within > *:not(figure):not(h3):not(.special) {
grid-column: 1;
}
.item:focus-within h3 {
background-image: linear-gradient(60deg, var(--color3), var(--color2));
color: #000;
font-size: 1.5rem;
font-weight: 400;
line-height: 2rem;
overflow: hidden;
text-shadow:
calc(-4 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc( 4 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc(-3 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc( 3 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc(-2 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc( 2 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc(-1 * (var(--h3-length) + var(--h3-offset))) 0 0,
calc( 1 * (var(--h3-length) + var(--h3-offset))) 0 0
;
top: 0;
}
.item + .item:focus-within h3 {
--h3-length: 6ch;
}
.item + .item + .item:focus-within h3 {
--h3-length: 11ch;
}
.item:focus-within figure {
border: var(--border) solid;
border-left: 0;
border-right: 0;
position: relative;
margin: 0 -1rem;
}
.item:not(:focus-within) {
cursor: pointer;
margin-right: 11px;
place-content: center;
place-items: center;
}
.item:not(:focus-within) h3 {
margin-bottom: 1rem;
}
.item:not(:focus-within) figure {
border: var(--border) solid;
box-shadow:
0.5rem 0.5rem var(--color2),
0.5rem 0.5rem 0 var(--border) #000
;
margin-bottom: 1rem;
transition: box-shadow 100ms;
}
.item:not(:focus-within):hover figure {
background-image: linear-gradient(45deg, var(--color2), var(--color4));
background-position: center;
background-repeat: no-repeat;
box-shadow:
1rem -1rem var(--color4),
1rem -1rem 0 1px ,
-1rem 1rem var(--color3),
-1rem 1rem 0 1px
;
}
.item:not(:focus-within):hover img {
mix-blend-mode: darken;
}
.item:not(:focus-within) figcaption {
display: none;
}
.item:not(:focus-within) > *:not(h3):not(figure) {
display: none;
}
.options {
display: grid;
grid-template-columns: 1fr 3fr;
}
.options strong {
display: block;
}
.options input[type="radio"] {
opacity: 0;
position: absolute;
}
.options label:not([for="quantity-select"]) {
box-shadow: 0 0 0 1px;
cursor: pointer;
display: inline-block;
margin-bottom: .5rem;
min-width: 3ch;
overflow: hidden;
padding: 0.5rem;
text-align: center;
transition: box-shadow 100ms;
}
.options input[type="radio"]:checked + label {
background-color: #000;
box-shadow:
var(--border) var(--border) var(--color2),
var(--border) var(--border) 0 1px #000;
color: #fff;
}
.options input[type="radio"]:disabled + label {
opacity: 0.5;
position: relative;
}
.price {
animation: shadow 1s linear infinite alternate;
aspect-ratio: 1 / 1;
background-color: var(--color2);
border: 1px solid;
box-shadow:
0.5rem 0.5rem var(--color4),
0.5rem 0.5rem 0 1px #000
;
display: flex;
font-size: 2rem;
line-height: 2rem;
place-items: center;
position: absolute;
top: 2rem;
text-align: center;
width: 4ch;
z-index: 10;
}
@keyframes shadow {
from {
box-shadow:
0.75rem 0.75rem var(--color4),
0.75rem 0.75rem 0 1px #000
;
top: 2.5rem;
}
}
.special {
align-items: center;
animation: special 2s linear infinite;
background-color: #f00;
border-bottom: var(--border) solid #000;
color: #fff;
display: flex;
grid-column: span 2;
grid-row: 2;
height: 2rem;
justify-content: center;
margin: 0 -1rem;
overflow: hidden;
text-shadow:
calc(-4 * 16ch) 0 0,
calc(-3 * 16ch) 0 0,
calc( 3 * 16ch) 0 0,
calc(-2 * 16ch) 0 0,
calc( 2 * 16ch) 0 0,
calc(-1 * 16ch) 0 0,
calc( 1 * 16ch) 0 0
;
white-space: nowrap;
}
@keyframes special {
from {
text-indent: 32ch;
}
}
// This is to *try* to circumvent this weird rendering bug I get in Chrome where the shadows stack all over each other
window.onload = function(){document.getElementsByTagName('h2')[0].style.left = 0};
Also see: Tab Triggers