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>
<div class="container">
<div class="branding">
<svg xmlns="http://www.w3.org/2000/svg" class="logo" viewBox="0 0 512 512" aria-hidden="true"><g fill="none" fill-rule="evenodd"><path fill="var(--color-logo-basket)" d="M397.474 496.517H113.322c-18.37 0-34.317-12.638-38.505-30.514L31.61 281.57h447.567l-43.198 184.434c-4.189 17.876-20.136 30.514-38.505 30.514"/><path fill="var(--color-logo-topping)" d="m428.977 212.086.11-.025-.715-.252v-.008c.219.092.496.168.715.26-.118-1.227-.093-2.295-.261-3.573-15.501-116.05-94.815-98.923-148.712-117.8-53.888-18.876-14.475-70.956-14.475-70.956-92.763-23.77-164.096 88.084-164.096 88.084C37.21 135.782 79.17 208.488 79.17 208.488c-29.084 23.257-33.946 49.894-29.74 73.084h399.624c9.58-41.495 2.944-59.488-20.077-69.486"/><path fill="#010202" d="M378.027 274.866c-.177 2.362-.11 4.548.025 6.71h71.005c9.664-41.874 2.842-59.825-20.691-69.772.227.092.505.16.723.26-.126-1.227-.092-2.303-.26-3.573-15.502-116.05-94.816-98.923-148.713-117.799h-.008s104.866 93.525 97.919 184.174" opacity=".3"/><path fill="#010202" d="M290.378 496.517h107.096c18.369 0 34.316-12.638 38.505-30.514l43.198-184.434H378.053s1.556 159.798-87.675 214.948" opacity=".3"/><path fill="#2E2E30" d="M423.69 463.124c-2.868 12.234-13.642 20.785-26.216 20.785h-13.87l22.777-189.723h56.882L423.69 463.124Zm-65.503 20.785h-51.172l7.89-189.723h66.058l-22.776 189.723Zm-76.438 0h-52.71l-7.899-189.723h68.507l-7.898 189.723Zm-129.149 0-22.776-189.723h66.059l7.897 189.723H152.6Zm-39.278 0c-12.574 0-23.357-8.551-26.225-20.785L47.524 294.186h56.89l22.777 189.723h-13.87Zm-34.914-257.78c.463.463 1.026 1.01 1.523 1.497.395.387.782.774 1.202 1.178 1.001.983 2.086 2.018 3.222 3.094.454.42.891.84 1.362 1.278 1.22 1.135 2.515 2.32 3.87 3.54.487.437.958.866 1.463 1.32a384.017 384.017 0 0 0 4.533 3.952c.522.445 1.018.874 1.548 1.328a308.7 308.7 0 0 0 5.248 4.347c.522.43 1.035.85 1.573 1.287a331.75 331.75 0 0 0 6.03 4.742c.514.395 1.002.782 1.523 1.177a367.752 367.752 0 0 0 6.88 5.112c.471.345.925.681 1.405 1.034a391.09 391.09 0 0 0 7.864 5.5c.378.26.748.52 1.135.781.816.555 1.573 1.102 2.414 1.657H60.746c-.438-16.06 5.39-30.202 17.662-42.823Zm2.17-81.071c3.138-9.434 9.58-16.842 19.598-22.5.445.319 1.043.731 1.53 1.076.547.387 1.077.756 1.683 1.177 1.21.85 2.565 1.766 4.003 2.733.69.462 1.312.882 2.044 1.37a361.436 361.436 0 0 0 6.359 4.103c.344.21.63.404.984.623a375.748 375.748 0 0 0 8.638 5.246c.857.505 1.808 1.043 2.7 1.556a406.477 406.477 0 0 0 7.25 4.128c1.261.706 2.582 1.413 3.894 2.127a480.754 480.754 0 0 0 7.469 3.96c1.48.774 2.977 1.54 4.525 2.321a526.58 526.58 0 0 0 8.385 4.12c1.573.757 3.112 1.505 4.736 2.27 3.39 1.581 6.922 3.17 10.53 4.76 1.27.555 2.464 1.11 3.76 1.673a529.048 529.048 0 0 0 15.5 6.382c1.044.403 2.162.799 3.222 1.21a497.365 497.365 0 0 0 13.45 4.978c1.942.69 3.952 1.354 5.946 2.035a503.37 503.37 0 0 0 12.002 3.943c2.296.724 4.626 1.43 6.972 2.136a510.951 510.951 0 0 0 12.406 3.548c2.431.673 4.853 1.337 7.335 1.985 4.567 1.185 9.252 2.304 13.987 3.405 2.254.521 4.45 1.068 6.737 1.572 7.065 1.547 14.282 3.01 21.725 4.33 19.177 3.414 36.327 5.886 51.887 8.039 3.213.445 6.45.9 9.52 1.32.093.008.177.025.278.034 4.29.588 8.37 1.152 12.347 1.706 1.178.169 2.313.337 3.457.497 3.28.47 6.401.933 9.454 1.404 1.06.168 2.17.328 3.213.496 3.474.555 6.737 1.118 9.883 1.707 1.312.243 2.54.496 3.793.748 1.96.395 3.835.807 5.652 1.228 1.27.294 2.549.588 3.751.9 2.6.664 5.072 1.361 7.326 2.118.665.219 1.228.48 1.867.706 7.46 2.725 12.953 6.063 16.057 10.544 4.76 6.912 5.543 18.532 2.355 36.18H181.02a362.672 362.672 0 0 1-43.737-26.51c-.294-.21-.597-.42-.891-.63a356.25 356.25 0 0 1-6.03-4.398c-.489-.37-.993-.732-1.473-1.093-1.8-1.363-3.532-2.691-5.215-4.011-.563-.437-1.127-.875-1.673-1.312a388.404 388.404 0 0 1-4.559-3.683c-.572-.462-1.127-.925-1.682-1.387a454.318 454.318 0 0 1-4.004-3.38c-.546-.47-1.068-.933-1.598-1.396a248.513 248.513 0 0 1-3.482-3.069c-.53-.47-1.01-.916-1.514-1.379a282.022 282.022 0 0 1-2.969-2.724c-.454-.429-.858-.816-1.295-1.228a295.144 295.144 0 0 1-4.651-4.532c-.32-.32-.707-.69-1.001-1-.395-.387-.69-.698-1.043-1.068-.572-.58-1.16-1.186-1.64-1.69-.253-.27-.446-.48-.682-.723-.47-.505-.95-1.018-1.312-1.413-.126-.143-.235-.252-.344-.387-.261-.277-.471-.512-.656-.714-2.919-5.558-16.57-33.406-8.992-56.167ZM245.633 29.243c-4.996 11.15-9.076 26.25-4.61 41.049 4.492 14.891 16.242 25.763 34.922 32.304 12.734 4.457 26.62 7.021 40.044 9.502 42.744 7.895 83.293 15.387 97.55 81.87-1.153-.269-2.448-.496-3.634-.756-.303-.06-.622-.126-.917-.185a326.448 326.448 0 0 0-12.515-2.371c-.707-.118-1.422-.244-2.137-.362-4.13-.673-8.47-1.345-13.011-2.001-.833-.126-1.649-.252-2.498-.37a2585.558 2585.558 0 0 0-16.048-2.237c-2.229-.302-4.6-.639-6.905-.95-15.998-2.203-33.72-4.725-53.51-8.24-6.914-1.227-13.617-2.598-20.211-4.044-2.019-.437-3.987-.917-5.98-1.38-4.584-1.059-9.101-2.152-13.517-3.295a510.871 510.871 0 0 1-6.224-1.657 475.732 475.732 0 0 1-13.188-3.792c-1.581-.47-3.213-.933-4.769-1.42a503.81 503.81 0 0 1-16.78-5.542c-.79-.277-1.522-.563-2.304-.84a485.147 485.147 0 0 1-13.432-4.995c-1.632-.63-3.213-1.27-4.803-1.909a484.301 484.301 0 0 1-10.143-4.179 616.36 616.36 0 0 1-4.55-1.95 493.506 493.506 0 0 1-10.279-4.65c-.942-.437-1.934-.874-2.85-1.312a472.04 472.04 0 0 1-11.961-5.877c-.866-.437-1.657-.866-2.507-1.303a426.56 426.56 0 0 1-11.598-6.214 399.35 399.35 0 0 1-6.62-3.75 346.361 346.361 0 0 1-9.74-5.818l-.874-.53a306.647 306.647 0 0 1-6.787-4.347c-.471-.303-.867-.572-1.313-.866a198.545 198.545 0 0 1-2.842-1.926c17.528-23.181 66.563-79.609 126.54-75.657Zm243.426 244.503a12.595 12.595 0 0 0-9.882-4.785h-14.904c3.423-22.542 1.186-38.543-7.082-50.516-4.147-6.012-9.656-10.611-16.284-14.387-14.046-97.073-72.913-108.003-120.334-116.765-13.062-2.404-25.392-4.691-36.284-8.509-10.623-3.716-17.049-9.005-19.093-15.723-3.852-12.62 6.292-30.085 10.506-35.718a12.617 12.617 0 0 0 1.85-11.78 12.634 12.634 0 0 0-8.781-8.055c-92.62-23.703-163.019 71.722-175.829 90.48-18.403 8.905-30.682 22.055-36.351 39.242-8.622 26.107.807 54.09 7.056 68.24-18.899 17.994-28.344 39.612-27.957 63.491h-4.071A12.619 12.619 0 0 0 19.33 284.45l43.198 184.426c5.56 23.703 26.435 40.258 50.793 40.258h284.152c24.35 0 45.233-16.555 50.793-40.258l43.198-184.426a12.623 12.623 0 0 0-2.406-10.703Z"/></g></svg>
<h1>The cupcake factory</h1>
</div>
<nav>
<ul>
<li><a href="#" class="active" aria-current="page">Home</a></li>
<li><a href="#">Our cupcakes</a></li>
<li><a href="#">About us</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</div>
</header>
<main>
<section class="intro container">
<h2>Not just a cupcake shop</h2>
<p>Wafer tootsie roll jelly dragée bonbon jelly. Cupcake toffee tiramisu croissant marshmallow tart croissant topping. Danish cupcake jelly-o ice cream fruitcake. Lollipop shortbread pie chocolate ice cream chocolate bar gummies.</p>
</section>
<section class="cupcakes">
<div class="container">
<div class="cupcake">
<img src="https://source.unsplash.com/90HdOlGbjck/w=600" alt="cupcake photo by Deva Williamson on Unsplash">
<a href="#">Le chocolat</a>
</div>
<div class="cupcake">
<img src="https://source.unsplash.com/9zr3elT4MHM/w=600" alt="cupcake photo by Deva Williamson on Unsplash">
<a href="#">The big momma</a>
</div>
<div class="cupcake">
<img src="https://source.unsplash.com/S2jw81lfrG0/w=600" alt="cupcake photo by Deva Williamson on Unsplash">
<a href="#">The lazarus</a>
</div>
<div class="cupcake">
<img src="https://source.unsplash.com/ymy-t_sKkNk/w=600" alt="cupcake photo by Deva Williamson on Unsplash">
<a href="#">The unicorn sparkle</a>
</div>
</div>
</section>
<section class="cta">
<div class="container">
<blockquote>
These cupcakes are the best cupcakes in the whole world! Absolutely love them
</blockquote>
<div>
<img src="https://source.unsplash.com/lEbNZsn0ujM/w=600" alt="Yum! photo by Deva Williamson on Unsplash">
</div>
</div>
</section>
</main>
<footer>
© Cupcake factory demo by <a href="https://utilitybend.com" target="_blank">utilitybend</a><br/>
Special shoutout to <a href="https://unsplash.com/@biglaughkitchen" target="_blank">Deva Williamson</a>, photos on <a href="https://unsplash.com/">unsplash</a>
</footer>
@import "https://unpkg.com/normalize.css";
@import url('https://fonts.googleapis.com/css2?family=Courgette&family=Source+Sans+Pro:wght@400;700&display=swap');
:root {
--color-champagne: #EFD9CE;
--color-tiffany: #07BEB8;
--color-blizzard: #98DFEA;
--color-plum: #8F3985;
--color-space: #25283D;
--color-lightest: #FAFAFA;
--color-logo-basket: #F8E6C4;
--color-logo-topping: #FF89C0;
@media (prefers-contrast: more) {
--color-champagne: #F8E1D5;
--color-tiffany: #31E3DD;
--color-plum: #591D52;
--color-logo-topping: #FFAED3;
}
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
background: var(--color-champagne);
color: var(--color-space);
font-family: 'Source Sans Pro', sans-serif;
font-size: 1.1rem;
line-height: 1.6;
}
h2 {
color: var(--color-plum);
font-size: 2rem;
font-family: 'Courgette', cursive;
margin-block-end: 0;
}
header {
padding-block : 24px;
background: var(--color-plum);
box-shadow: rgba(9, 30, 66, 0.25) 0px 4px 8px -2px, rgba(9, 30, 66, 0.08) 0px 0px 0px 1px;
.container {
display: flex;
flex-direction: column;
align-items: center;
@media screen and (min-width: 1000px) {
flex-direction: row;
justify-content: space-between;
gap: 50px;
}
}
}
.branding {
font-family: 'Courgette', cursive;
display: flex;
align-items: center;
gap: 20px;
color: var(--color-champagne);
h1 {
margin: 0;
font-size: 1.6rem;
@media screen and (min-width: 500px) {
font-size: 2rem;
}
}
}
nav ul {
display: flex;
gap: 15px;
margin-block: 15px 0;
margin-inline: 0;
padding: 0;
list-style: none;
font-size: 1rem;
@media screen and (min-width: 1000px) {
margin-block-start: 0;
font-size: 1.4rem;
}
a, a:link, a:visited {
color: var(--color-logo-topping);
text-decoration: none;
transition: color .24s;
&.active {
color: var(--color-champagne);
@media (prefers-contrast: more) {
text-decoration: underline;
}
}
}
a:hover, a:focus, a:active {
color: var(--color-champagne);
}
}
.cupcakes {
padding-block: 60px;
.container {
display: grid;
gap: 24px;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
}
}
.cupcake {
position: relative;
border-radius: 20px;
overflow: hidden;
background: var(--color-tiffany);
transition: background-color .2s;
font-size: 1.3rem;
box-shadow: rgba(0, 0, 0, 0.1) -4px 9px 25px -6px;
img {
aspect-ratio: 4/5;
object-fit: cover;
object-position: bottom;
}
a {
display: block;
padding: 15px;
font-family: 'Courgette', cursive;
color: var(--color-plum);
text-decoration: none;
@media (prefers-contrast: more) {
text-decoration: underline;
}
&::after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
content: '';
}
}
&:has(:hover, :focus) {
background: var(--color-blizzard);
}
}
.cta {
padding-block-start: 30px;
background-image: linear-gradient(var(--color-blizzard) 80%, var(--color-champagne) 80%);
@media screen and (min-width: 800px) {
padding-block-start: 0;
background-image: linear-gradient(90deg, var(--color-blizzard) 50%, var(--color-champagne) 50%);
}
.container {
display: grid;
font-family: 'Courgette', cursive;
font-size: 2.2rem;
line-height: 1.6;
color: var(--color-logo-topping);
@media screen and (min-width: 800px) {
grid-template-columns: repeat(2, 1fr);
}
@media (prefers-contrast: more) {
color: var(--color-plum);
}
}
}
footer {
padding: 20px;
margin-block-start: 50px;
text-align: center;
background: var(--color-plum);
color: var(--color-lightest);
a {
color: var(--color-champagne);
}
}
/****
Generic demo styles
*/
.container {
max-width: 1200px;
padding-inline: 12px;
margin-inline: auto;
}
p {
margin-block-start: 0;
}
img {
display: block;
width: 100%;
max-width: 100%;
}
main {
flex: 1;
}
.logo {
display: block;
width: 50px;
}
.intro {
padding-block: 30px 0;
> * {
max-width: 600px;
}
}
blockquote {
display: flex;
align-items: center;
margin: 0;
padding-block: 20px;
padding-inline-end: 30px;
}
Also see: Tab Triggers