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.
<div class="bl_mario">
<div class="bl_mario_itemRed1"></div>
<div class="bl_mario_itemRed2"></div>
<div class="bl_mario_itemRed3"></div>
<div class="bl_mario_itemRed4"></div>
<div class="bl_mario_itemRed5"></div>
<div class="bl_mario_itemRed6"></div>
<div class="bl_mario_itemRed7"></div>
<div class="bl_mario_itemRed8"></div>
<div class="bl_mario_itemRed9"></div>
<div class="bl_mario_itemRed10"></div>
<div class="bl_mario_itemRed11"></div>
<div class="bl_mario_itemRed12"></div>
<div class="bl_mario_itemRed13"></div>
<div class="bl_mario_itemGre1"></div>
<div class="bl_mario_itemGre2"></div>
<div class="bl_mario_itemGre3"></div>
<div class="bl_mario_itemGre4"></div>
<div class="bl_mario_itemGre5"></div>
<div class="bl_mario_itemGre6"></div>
<div class="bl_mario_itemGre7"></div>
<div class="bl_mario_itemGre8"></div>
<div class="bl_mario_itemGre9"></div>
<div class="bl_mario_itemGre10"></div>
<div class="bl_mario_itemGre11"></div>
<div class="bl_mario_itemGre12"></div>
<div class="bl_mario_itemGre13"></div>
<div class="bl_mario_itemGre14"></div>
<div class="bl_mario_itemGre15"></div>
<div class="bl_mario_itemGre16"></div>
<div class="bl_mario_itemGre17"></div>
<div class="bl_mario_itemGre18"></div>
<div class="bl_mario_itemGre19"></div>
<div class="bl_mario_itemGre20"></div>
<div class="bl_mario_itemGre21"></div>
<div class="bl_mario_itemYel1"></div>
<div class="bl_mario_itemYel2"></div>
<div class="bl_mario_itemYel3"></div>
<div class="bl_mario_itemYel4"></div>
<div class="bl_mario_itemYel5"></div>
<div class="bl_mario_itemYel6"></div>
<div class="bl_mario_itemYel7"></div>
<div class="bl_mario_itemYel8"></div>
<div class="bl_mario_itemYel9"></div>
<div class="bl_mario_itemYel10"></div>
<div class="bl_mario_itemYel11"></div>
<div class="bl_mario_itemYel12"></div>
<div class="bl_mario_itemYel13"></div>
<div class="bl_mario_itemYel14"></div>
<div class="bl_mario_itemYel15"></div>
</div>
$pixel: 10px;
$red: #db2900;
$green: #8a7301;
$yellow: #ffa33c;
.bl_mario {
display: grid;
grid-template-columns: 1fr repeat(12, $pixel) 1fr;
grid-template-rows: repeat(16, $pixel);
grid-template-areas :
"... ... ... ... r01 r01 r01 r01 r01 ... ... ... ..."
"... ... ... r02 r02 r02 r02 r02 r02 r02 r02 r02 ..."
"... ... ... g01 g01 g01 y01 y01 g02 y02 ... ... ..."
"... ... g04 y05 g03 y03 y01 y01 g02 y02 y04 y04 ..."
"... ... g04 y05 g03 g05 y01 y01 y06 g06 y04 y04 y07"
"... ... g07 g07 y08 y08 y01 y01 g08 g08 g08 g08 ..."
"... ... ... ... y09 y09 y09 y09 y09 y09 y09 ... ..."
"... ... ... g09 g09 r03 g10 g10 g10 ... ... ... ..."
"... ... g13 g09 g09 r03 g11 g11 r04 g12 g12 g12 ..."
"... g14 g14 g14 g14 r05 r05 r05 r05 g12 g12 g12 g15"
"... y10 y10 g16 r06 y11 r07 r07 y12 r08 g17 y13 y13"
"... y10 y10 y14 r09 r09 r09 r09 r09 r09 y15 y13 y13"
"... y10 y10 r10 r09 r09 r09 r09 r09 r09 r11 y13 y13"
"... ... ... r12 r12 r12 ... ... r13 r13 r13 ... ..."
"... ... g18 g18 g18 ... ... ... ... g19 g19 g19 ..."
"... g20 g18 g18 g18 ... ... ... ... g19 g19 g19 g21";
@for $i from 1 through 21 {
&_itemRed#{$i} {
@if $i < 10 {
grid-area: r0#{$i};
} @else {
grid-area: r#{$i};
}
background-color: $red;
}
&_itemGre#{$i} {
@if $i < 10 {
grid-area: g0#{$i};
} @else {
grid-area: g#{$i};
}
background-color: $green
}
&_itemYel#{$i} {
@if $i < 10 {
grid-area: y0#{$i};
} @else {
grid-area: y#{$i};
}
background-color: $yellow;
}
}
}
Also see: Tab Triggers