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 Apple tart
section
h2 The shell
aside.oven-instructions Preheat the oven to 400°.
aside.ingredients
ul
li 7 tablespoons frozen butter*
li 1 cup frozen flour*
li 3 tablespoons ice-cold water*
li 1 teaspoon cider vinegar
li A pinch of kosher salt
p.note It is important to have these ingredients as cold as possible
article
p In a food processor fitted with a steel blade, combine all theingredients until they form a solid mass that rises above the blade. You can add extra water by the tablespoon if the mass does not congeal within the first minute. Tiny pieces of butter should still be visible in the dough when it's done. Remove the dough from the bowl and work it quickly into a ball on a lightly floured surface. Cover with plastic wrap and refrigerate for at least half an hour.
p After the dough has rested in the refrigerator, roll it out on a lightly floured surface until it forms a circle approximately 13" in diameter. Center the cirlce of dough in a 10-inch tart pan with a removeable bottom. Use your knuckles to make sure that the dough tucks neatly against the edge of the pan and run the rolling pin around the rim to remove the excess. Cover and refrigerate again for at least half an hour.
p Line the tart shell with aluminum foil, being careful.ingredients to cove the edges. Pierce the aluminum and the dough several times with a fork and fill the shell with dried lentils. Bake for 20 minutes. Remove the aluminum and the lentils and continue baking until the shell is golden brown, about 15 minutes more.
section
h2 The apples
aside.ingredients
ul
li 6 Granny Smith apples
li Juice of one lemon
li Cinnamon to taste
li Nutmeg to taste
article
p Peel, core and halve the apples. Either by hand or with a food processor, cut the apple halves crosswise into thin (less than ¼") slices. In a large bowl, toss the apples in the lemon juice, cinnamon and nutmeg. Cover and set aside.
section
h2 The pastry cream
aside.ingredients
ul
li ¼ cup sugar
li 1 tablespoon flour
li 2 teaspoons cornstarch
li 1 large egg
li 1 cup milk
li 3 tablespoons unsalted butter
li ¼ teaspoon vanilla extract
article
p Sift the sugar, flour and cornstarch together in a mixing bowl. Add the egg and beat until light. In a heavy-bottomed saucepan, bring the milk to a boil. Stir half the milk into the egg mixture, then pour the whole mixture back into the saucepan. Cook over high heat, stirring constantly, until the center bubbles and the mixture is very thick. Remove from heat and stir in the vanilla and the butter. Pour the pastry cream into a bowl, cover tightly with plastic wrap and refrigerate. (Be sure to press the plastic wrap right onto the cream to prevent a skin from forming.)
section
h2 The assembly and baking
p.oven-instructions Preheat the oven to 375°.
ul.ingredients
li 2 tablespoons sugar
li 8 ounces currant jelly
article
p Spread the pastry cream over the bottom of the shell. Arrange the apple slices in a circle around the outer edge of the shell, making sure the slices overlap. When the outer circle is completed, make a smaller circle, overlapping about half of the outer circle. If there's room, make a third circle. Fill the hole in the center with pieces of a few slices—let them stand upright. Cover the tart with a circle of wax paper and bake for 25 minutes. Remove the wax paper and sprinkle the sugar over the apples. Bake uncovered for 5–10 minutes more, until the sugar melts.
p Boil the currant jelly until it reduces by one-third. With a pastry brush, paint the top of the tart with the currant glaze. Allow time for the glaze to set before serving (10 minutes).
*, *::before, *::after {
box-sizing: inherit;
}
body {
box-sizing: border-box;
}
body {
padding: 3em 6ch;
margin: 0;
font-family: "Adobe Garamond Pro", Garamond, serif;
font-weight: 400;
line-height: calc(1 + 2/3);
}
section {
display: grid;
grid-template-columns: 2fr 4fr 1fr;
grid-column: span 3;
grid-auto-flow: row;
margin-top: 1rem;
}
h1, h2, article {
grid-column: 2;
margin-bottom: 1rem;
}
h2 {
font-family: Univers, "Gill Sans", "Myriad Pro", sans-serif;
font-weight: 700;
}
p + p {
margin-top: 1rem;
}
.oven-instructions {
grid-column: 3;
grid-row: 2;
margin-left: 4ch;
}
.ingredients {
grid-column: 1;
margin-right: 4ch;
}
.note {
font-style: italic;
margin-top: 1rem;
}
.note::before {
content: "*";
display: block;
float:left;
margin-left: -2ch;
}
@media screen and (max-width: 120ch) {
body, section {
grid-template-columns: 1fr 2fr;
}
section {
grid-column: span 2;
}
.oven-instructions {
grid-column: 2;
grid-row: initial !important;
margin-left: 0;
margin-bottom: 1rem;
}
}
@media screen and (max-width: 80ch) {
body {
padding: 1em 4ch;
grid-template-columns: 1fr;
}
section {
display: block;
}
h1 {
grid-column: 1;
}
.ingredients {
padding-top: 1rem;
padding-bottom: 1rem;
margin-bottom: 1rem;
}
}
@media screen and (max-width: 50ch) {
body {
font-size: .875em;
}
}
@media screen and (max-width: 40ch) {
body {
font-size: .75em;
}
}
@media screen and (min-width: 180ch) {
body {
font-size: 1.125em;
}
}
Also see: Tab Triggers