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.
<h1>Pasta with Pesto and Tomatoes</h1>
<figure>
<img src="https://images.unsplash.com/photo-1593253787226-567eda4ad32d?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=2434&q=80" alt="spaghetti with pesto sauce and cherry tomatoes.">
<figcaption>Photo by Shania Pinnata</figcaption>
</figure>
<div class="description">
<p>This quick and delicious pasta dish is the perfect way to use up a summer bounty of basil and tomatoes! </p>
<p>Don't have a green thumb? Never fear! You can knock out this classic pasta dish in no time with a jar of prepared pesto sauce. </p>
<figure>
<img src="https://images.unsplash.com/photo-1606923829579-0cb981a83e2e?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80" alt="tomato halves surrounded by basil leaves and peppercorns.">
<figcaption>Photo by Tamanna Rumee</figcaption>
</figure>
</div>
<div class="recipe_details">
<ul>
<li>Servings: 4</li>
<li>Prep Time: 5 minutes</li>
<li>Cook Time: 25 minutes</li>
<li>Total Time: 30 minutes</li>
</ul>
</div>
<h2>The Ingredients</h2>
<ul class="ingredients">
<li>8 oz. spaghetti or linguine pasta</li>
<li>2 cups fresh basil leaves, plus 4-8 reserved leaves for garnish</li>
<li>2 cloves garlic</li>
<li>2 tbsp. pine nuts or blanched almonds</li>
<li>1/2 cup olive oil</li>
<li>1/2 cup grated Parmesan cheese, plus 2 tbsp. for garnish.</li>
<li>1/8 tsp salt</li>
<li>1 pint cherry tomatoes</li>
<li>1 tsp olive oil</li>
</ul>
<p class="variation">Variation: Got no time, or no fresh basil? Use a 6 ounce jar of prepared pesto instead.</p>
<h2>The Process</h2>
<ol class="instructions">
<li>Bring 4 quarts of water to a rolling boil in a large pot. Salt the water generously and add the pasta. </li>
<li>While the pasta cooks, make the pesto.
<ul>
<li>Remove stems from basil leaves.</li>
<li>Put the basil, garlic, and pine nuts or almonds into the bowl of a food processor and pulse it a few times to chop them up.</li>
<li>Then, turn the food processor on and <strong>slowly</strong> pour the olive oil through the feeder tube to blend with the chopped herbs and nuts. </li>
<li>Process until all ingredients are fully blended, stopping the food processor to scrape down the sides occasionally to get it all mixed. </li>
<li>Turn off the food processor, and add the salt and Parmesean, then pulse a few times to blend.</li>
</ul>
</li>
<li>Heat a large skillet over medium heat. </li>
<li>Add the 1/2 tsp. olive oil to the heated skillet.</li>
<li>Add the cherry tomatoes to the skillet and let them blister, stirring occasionally and gently so they don't burst. </li>
<li>Remove tomatoes from the pan and set aside. </li>
<li>Drain the pasta, reserving 1/4 cup of the cooking water.</li>
<li>Return the pasta to the pot</li>
<li>Add the reserved cooking water and pesto to the pasta and stir to mix</li>
<li>Plate the pasta and add 6-8 tomatoes to each plate</li>
<li>Garnish with reserved basil leaves and Parmesean and serve. Buon Appetito!</li>
</ol>
@import url("https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Merriweather:wght@300;900&display=swap");
:root {
--color1: #cd8343;
--color2: #fdc3b2;
--color3: #fdfee0;
--color4: #468a62;
--color5: #2a6341;
--shadow-offset: 1.3rem 1.3rem;
}
html {
background-color: var(--color3);
}
body {
display: grid;
grid-template-columns: repeat(4, 1fr);
margin: 0 auto;
font-family: "Merriweather";
max-width: 90vw;
}
h1,
h2 {
font-family: "DM Serif Display", serif;
}
h1 {
background-color: #fffc;
backdrop-filter: blur(5px);
border: 3px solid black;
box-shadow: 1rem 1rem var(--color4);
font-size: 3rem;
left: 1rem;
letter-spacing: -0.03em;
line-height: 1;
margin: 0;
max-width: calc(50% - 4rem);
padding: 0.5rem 1rem;
position: absolute;
top: 2rem;
}
h2 {
display: none;
}
figure {
/* align-self: end; */
grid-column: span 2;
margin: 1rem 0 0;
padding-right: 5rem;
}
figcaption {
font-size: 0.8em;
padding-left: 2rem;
}
figure img {
--shadow: var(--color2);
display: block;
/* margin-left: auto; */
/* max-height: 80vh; */
max-width: 100%;
border: 3px solid;
box-shadow: var(--shadow-offset) var(--shadow);
}
ul {
list-style: none;
}
.description {
grid-column: span 2;
padding: 1rem;
}
.description figcaption {
color: var(--color3);
text-align: end;
}
.description figure {
margin-bottom: 1rem;
margin-top: 1rem;
padding-right: 0;
}
.description img {
--shadow: var(--color5);
margin-left: -1rem;
}
.description p {
padding: 0 1rem;
font-size: 1.3em;
line-height: 1.5;
color: var(--color5);
}
.recipe_details {
grid-column: span 4;
}
.recipe_details ul {
background-color: #fff;
border: 3px solid;
column-gap: 2rem;
display: grid;
font-family: "DM Serif Display", serif;
font-size: 1.5rem;
grid-template-columns: repeat(3, 1fr);
margin-top: 3rem;
position: relative;
padding: 0;
text-align: center;
filter: drop-shadow(1rem 1rem var(--color1));
}
.recipe_details li {
line-height: 1.5;
margin: 0.5rem 0;
position: relative;
}
.recipe_details li:first-child {
background-color: #fff;
box-shadow: 0 6px 0 #fff, 0 0 0 3px;
grid-column-start: 2;
padding: 0.3em 3rem;
position: absolute;
right: 33.3%;
top: calc((1.5rem * -1.5) - 1.2em + 3px);
}
.recipe_details li:nth-child(2)::after,
.recipe_details li:nth-child(3)::after {
color: var(--color1);
content: "❈";
position: absolute;
right: -1rem;
}
.recipe_details li:nth-child(2) {
grid-column-start: 1;
}
.ingredients {
background-color: #fffc;
grid-column: span 3;
position: relative;
padding: 1rem;
padding-left: 6rem;
border: 3px solid;
box-shadow: inset 4em 0 #fff, inset calc(4em + 3px) 0, 1rem 1rem var(--color4);
}
.ingredients::before {
content: "The Ingredients";
font-family: "DM Serif Display", serif;
font-size: 2rem;
left: 2em;
line-height: 2;
position: absolute;
top: calc(100% - 2em - 0.5em);
transform: rotate(-90deg);
transform-origin: bottom left;
}
.ingredients li {
font-size: 1.2rem;
margin-bottom: 0.3em;
padding-left: 1rem;
position: relative;
}
.ingredients li::before {
color: var(--color5);
content: "✺";
left: -0.5rem;
position: absolute;
}
.variation {
color: var(--color5);
display: flex;
font-size: 1.5rem;
padding: 0 2em;
place-items: center;
text-align: center;
}
.instructions {
--process: var(--color2);
--process-accent: var(--color1);
background-color: #fffc;
border: 3px solid;
box-shadow: 1rem 1rem 0 var(--process);
grid-column: span 4;
line-height: 1.5;
list-style: none;
margin: 4rem 2rem;
padding: 4rem 5rem 2rem;
position: relative;
}
.instructions::before {
content: "The Process";
counter-reset: instructions;
backdrop-filter: blur(5px);
background-color: #fffc;
border: 3px solid;
box-shadow: 1rem 1rem 0 var(--process);
font-family: "DM Serif Display", serif;
font-size: 2.5rem;
line-height: 1;
padding: 1rem;
position: absolute;
right: 3rem;
top: -3rem;
}
.instructions li {
font-size: 1.2rem;
margin-bottom: 0.75em;
position: relative;
}
.instructions > li {
counter-increment: instructions;
}
.instructions > li::before {
content: counter(instructions);
background-color: var(--process);
border-radius: 1em;
color: #fff;
font-family: "DM Serif Display", serif;
font-size: 1.2em;
left: -1.8em;
position: absolute;
text-align: center;
text-shadow: -1px -1px #000, -1px 0 #000, -1px 1px #000, 0 -1px #000,
0 1px #000, 1px -1px #000, 1px 0 #000, 1px 1px #000;
top: -0.15em;
width: 1.5em;
}
.instructions strong {
color: var(--process-accent);
letter-spacing: 0.08em;
}
.instructions ul {
margin-top: 0.5em;
padding-left: 2.5rem;
}
.instructions ul li::before {
content: "❊";
color: var(--process-accent);
font-size: 1.3em;
left: -1.3em;
position: absolute;
top: -0.15em;
}
Also see: Tab Triggers