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.
%main.page
%header.site-header
%h1.site-header__title codepen kitchen
%article.recipe
%h2.recipe__title four-bean chili
<img class="recipe__headshot" src="https://pbs.twimg.com/profile_images/434065497554841600/VwVa5cy__bigger.png" alt="Chris Coyier"><h4 class="recipe__author">chris coyier</h4>
%p.recipe__cook-time Total time: 1 hr 30 min • Prep time: 20 min • Cook time: 1 hr 10 min
%p.recipe__description--hero My grandpappy used to make this chili over the campfire under the Texas stars. The secret ingredient was a little squeeze of scorpion venom in the pot.
%section.recipe-card
%h3.recipe-card__title ingredients
%ul.recipe-card__contents
%li.recipe-card__contents--list-item 1lb ground bison
%li.recipe-card__contents--list-item 1 cup diced onion
%li.recipe-card__contents--list-item 4 diced jalepeños
%li.recipe-card__contents--list-item 1 cup black beans
%li.recipe-card__contents--list-item 1 cup great northern beans
%li.recipe-card__contents--list-item 1 cup kidney beans
%li.recipe-card__contents--list-item 1 cup pinto beans
%li.recipe-card__contents--list-item 4 cloves garlic
%li.recipe-card__contents--list-item 2 tbsp mexican chili powder
%li.recipe-card__contents--list-item 2 tsp salt
%li.recipe-card__contents--list-item 2 tsp ground pepper
%li.recipe-card__contents--list-item 1 tsp cayenne
%li.recipe-card__contents--list-item 28oz smushed tomatoes
%li.recipe-card__contents--list-item 3 cups beef broth
%section.recipe-card
%h3.recipe-card__title directions
%p.recipe-card__contents Get your filthiest campfire-scorched Dutch oven over the fire the best you can situate it. Brown the bison. Add the diced onion and spices, sautee until soft. Add tomatoes and broth and bring to a simmer for 40 minutes. Add beans and cook another 30 minutes.
%p.recipe-card__contents Serve with Tabasco and a giant spoon.
@import "bourbon";
/* |Variables
============================== */
//colors
$c1: #fadd99; //tan
$c2: #ff94c0; //pink
$c3: darken(#71a6f7,5%); //baby-ish blue
$c4: #333333; //dark gray (it's explosive)
$c5: #dedede; //silver
$c6: #fefefe; //white
//fonts
$f1: 'Montserrat', sans-serif;
$f2: 'PT Mono', monospace;
/* |Styles
============================== */
* { @include box-sizing(border-box); }
html {
background: $c1 url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/chili.jpg) left top no-repeat fixed;
background-size: 786px 1089px;
color: $c4;
font-family: $f1;
font-size-adjust: auto;
-webkit-font-smoothing: antialiased;
}
.page {
background: $c1 url(https://i.imgur.com/PJt1bx5.png);
float: right;
width: 62%;
@include clearfix;
}
.site-header {
background-image:
repeating-linear-gradient(
90deg,
$c2,
$c2 36px,
lighten($c2,5%) 36px,
lighten($c2,5%) 72px);
border-bottom: 3px solid darken($c2,5%);
width: 100%;
&__title {
font: {
size: 3.375rem;
weight: 700;
}
line-height: 1;
margin: 0;
padding: 2rem 0 2.25rem;
text: {
align: center;
shadow: //can't do a proper text-stroke, so we do this instead. sorry mom.
1px 1px 0px $c6,
-1px 1px 0px $c6,
1px -1px 0px $c6,
-1px -1px 0px $c6;
transform: uppercase;
}
} //end .site-header__title
.icon-codepen-logo { position: relative; top: 0.25rem; }
} //end .site-header
.recipe {
margin: 0 auto;
max-width: 768px;
width: 90%;
&__title {
color: $c3;
font: {
size: 3.375rem;
weight: 700;
}
line-height: 1;
margin: 4.5rem 0 1rem;
text: {
shadow:
1px 0px 1px darken($c3,20%),
0px 1px 1px darken($c3,35%),
2px 1px 1px darken($c3,20%);
transform: uppercase;
}
} //end .recipe__title
&__headshot {
border-radius: 50%;
display: inline-block;
height: 54px;
position: relative;
width: 54px;
} //end .recipe__headshot
&__author {
display: inline-block;
font: {
size: 1.5rem;
weight: 700;
}
line-height: 1;
margin: 0 0 0.25rem 0.75rem;
text-transform: capitalize;
@include position(relative, -1.1rem 0 0 0);
} //end .recipe__author
&__cook-time {
font: {
size: 1rem;
weight: 400;
}
margin: 0.75rem 0 4.5rem;
} //end .recipe__cook-time
&__description--hero {
border-left: 1rem solid $c2;
font: {
size: 1.5rem;
weight: 400;
}
line-height: 1.5;
margin: 0 0 5rem;
padding-left: 1.25rem;
} //end .recipe__description--hero
} //end .recipe
.recipe-card {
background: $c6;
box-shadow: 0px 2px 6px lighten($c4,25%);
margin-bottom: 2.25rem;
padding: 1.5rem;
&__title {
color: $c3;
font: {
size: 2.25rem;
weight: 400;
}
line-height: 1;
margin: 0 0 1rem;
text-transform: capitalize;
} //end .recipe-card__title
&__contents {
font: {
family: $f2;
size: 1.5rem;
weight: 400;
}
line-height: 1.5;
margin: 0.5rem 0 1.5rem;
list-style-type: square;
} //end .recipe-card__contents
} //end .recipe-card
/* </> w/ <3 :) */
Also see: Tab Triggers