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.
<html>
<h3>Theme</h3>
<block style="background:var(--color-primary);color:var(--color-primary-text)" class="first">P</block>
<block style="background:var(--color-secondary);color:var(--color-secondary-text)">S</block>
<block style="background:var(--color-highlight);color:var(--color-highlight-text)">H</block>
<h3>Complementary</h3>
<block class="complementary">C</block>
<block class="complementary alt">C</block>
<block class="complementary light">CL</block>
<block class="complementary light alt">CL</block>
<block class="complementary dark" style="color:var(--color-primary-text)">CD</block>
<block class="complementary dark alt" style="color:var(--color-primary-text)">CD</block>
<h3>Split Complementary</h3>
<block class="split-complementary">SC</block>
<block class="split-complementary alt">SC</block>
<block class="split-complementary alt-2">SC</block>
<h3>Triadic</h3>
<block class="triadic">T</block>
<block class="triadic alt">T</block>
<block class="triadic alt-2">T</block>
<h3>Analagous</h3>
<block class="analagous">A</block>
<block class="analagous alt">A</block>
<block class="analagous alt-2">A</block>
<h3>Tetradic</h3>
<block class="tetradic">T</block>
<block class="tetradic alt">T</block>
<block class="tetradic alt-2">T</block>
<block class="tetradic alt-3">T</block>
<h3>Shades/Tint</h3>
<block class="luma l00">0</block>
<block class="luma l10">10</block>
<block class="luma l20">20</block>
<block class="luma l30">30</block>
<block class="luma l40">40</block>
<block class="luma l50">50</block>
<block class="luma l60">60</block>
<block class="luma l70">70</block>
<block class="luma l80">80</block>
<block class="luma l90">90</block>
<block class="luma l100">00</block>
<h3>Tones</h3>
<block class="chroma c00">0</block>
<block class="chroma c10">10</block>
<block class="chroma c20">20</block>
<block class="chroma c30">30</block>
<block class="chroma c40">40</block>
<block class="chroma c50">50</block>
<block class="chroma c60">60</block>
<block class="chroma c70">70</block>
<block class="chroma c80">80</block>
<block class="chroma c90">90</block>
<block class="chroma c100">00</block>
<h3>MIX</h3>
<block class="mix m00">0</block>
<block class="mix m10">10</block>
<block class="mix m20">20</block>
<block class="mix m30">30</block>
<block class="mix m40">40</block>
<block class="mix m50">50</block>
<block class="mix m60">60</block>
<block class="mix m70">70</block>
<block class="mix m80">80</block>
<block class="mix m90">90</block>
<block class="mix m100">00</block>
<h3>Test</h3>
<block style="background:var(--test-color-0)">T0</block>
<block style="background:var(--test-color-1)">T1</block>
<block style="background:var(--test-color-2)">T2</block>
<block style="background:var(--test-color-3)">T3</block>
<block style="background:var(--test-color-4)">T4</block>
<block style="background:var(--test-color-5)">T5</block>
<block style="background:var(--test-color-6);color:var(--color-highlight-text)">T6</block>
<block style="background:var(--test-color-7);color:var(--color-highlight-text)">T7</block>
</html>
/*
* Erik Codekraft - 2022
* https://github.com/erikyo/
*/
/// Output the value for the property
/// @param {number or string} $val - the base value
/// @param {number} $val2 - the value to sum
/// @output the result or the css string calc(val1 + val2)
@function set_value($val, $val2) {
@if (type-of($val) == string) {
@return calc(#{$val} + #{$val2});
} @else {
@return $val + $val2;
}
}
/// Output a hsl color variation for a custom property
/// @param {list} $color - the Hue Saturation Luminosity values of the base color
/// @param {number} $hue - corresponds to the hue rotate scss function
/// @param {percentage} $saturation - corresponds to the saturate/desaturate scss function
/// @param {percentage} $luminosity - corresponds to the lighten/darken scss function
/// @param {percentage} $alpha - makes the colour transparent (the colour becomes a hsla)
/// @output a hsl color custom property in hsl or hsla depends on if the alpha argument has been passed
@function gen-custom-prop($color, $hue: false, $saturation: false, $luminosity: false, $alpha: false) {
@if (type_of($color) == string) {
@error("Error in _variables.scss: colors needs to be a list like 150, 100%, 50% and not " + $color)
}
$h: nth($color, 1);
$s: nth($color, 2);
$l: nth($color, 3);
@if($hue != false) {
$h: set_value($h, $hue);
}
@if($saturation != false) {
$s: set_value($s, $saturation);
}
@if($luminosity != false) {
$l: set_value($l, $luminosity);
}
@if($alpha != false) {
@return unquote("hsla(#{$h}, #{$s}, #{$l}, #{$alpha})");
}
@return unquote("hsl(#{$h}, #{$s}, #{$l})");
}
// THE SCSS WAY
// primary color
$color-primary: var(--color-hue), var(--color-sat), var(--color-luma);
$color-primary-text: var(--color-hue), calc(var(--color-sat) - 18%), calc(var(--color-luma) + 50%);
// secondary color
$color-secondary: var(--color-hue), var(--color-sat--secondary), calc(var(--color-luma) + 40%);
$color-secondary-text: var(--color-hue), var(--color-sat--secondary), calc(var(--color-luma) - 60%);
// highlight
$color-highlight: var(--color-hue--highlight), var(--color-sat), var(--color-luma);
$color-highlight-text: var(--color-hue--highlight), calc(var(--color-sat) + 18%), calc(var(--color-luma) + 50%);
// export vars as CSS vars
:root {
// test
--color-hue: 312;
--color-hue--highlight: calc(var(--color-hue) + 150);
--color-sat: 26%;
--color-sat--secondary: calc(var(--color-sat) - 21%);
--color-luma: 52%;
--color-luma-white: 100%;
--color-primary: hsl(#{$color-primary});
--color-primary-text: hsl(#{$color-primary-text});
--color-secondary: hsl(#{$color-secondary});
--color-secondary-text: hsl(#{$color-secondary-text});
--color-highlight: hsl(#{$color-highlight});
--color-highlight-text: hsl(#{$color-highlight-text});
--color-white: hsl(0,0%,var(--color-luma-white));
--color-black: hsl(0,0%,calc(var(--color-luma-white) * 0.05));
--test-color-0: #{gen-custom-prop( $color-primary )};
--test-color-1: #{gen-custom-prop( ( var(--color-hue--highlight), 2%, 100% ) )};
--test-color-2: #{gen-custom-prop( ( var(--color-hue--highlight), 50%, 0% ) , -30, 20%, +80%, .5 )};
--test-color-3: #{gen-custom-prop( ( var(--color-hue), 4%, 50% ) )};
--test-color-4: #{gen-custom-prop( $color-primary, -10 )};
--test-color-5: #{gen-custom-prop( $color-primary, false, 30% )};
--test-color-6: #{gen-custom-prop( $color-secondary, -120, 20%, -50% )};
--test-color-7: #{gen-custom-prop( $color-highlight, 60, false, false, 50% )};
}
$size: 80px;
html {
background-color: var(--color-black);
font-family: monospace;
}
h3 {
color: var(--color-white);
float: left;
clear: left;
margin: $size * .25 $size * .1 0;
letter-spacing: $size * .1;
font-size: $size * .3;
font-weight: 300;
}
block {
&.complementary {
background-color: var(--color-primary);
&.alt { background-color: #{gen-custom-prop( $color-primary, 180 )}; }
&.light { background-color: #{gen-custom-prop( $color-primary, false, false, 25% )}; }
&.light.alt { background-color: #{gen-custom-prop( $color-primary, 180, false, 25% )}; }
&.dark { background-color: #{gen-custom-prop( $color-primary, false, false, -25% )}; }
&.dark.alt { background-color: #{gen-custom-prop( $color-primary, 180, false, -25% )}; }
}
&.split-complementary {
background-color: var(--color-primary);
&.alt { background-color: #{gen-custom-prop( $color-primary, 150 )}; }
&.alt-2 { background-color: #{gen-custom-prop( $color-primary, -150 )}; }
}
&.triadic {
background-color:var(--color-primary);
&.alt { background-color: #{gen-custom-prop( $color-primary, 120 )}; }
&.alt-2 { background-color: #{gen-custom-prop( $color-primary, -120 )}; }
}
&.analagous {
background-color: var(--color-primary);
&.alt { background-color: #{gen-custom-prop( $color-primary, 30 )}; }
&.alt-2 { background-color: #{gen-custom-prop( $color-primary, 60 )}; }
}
&.tetradic {
background-color: var(--color-primary);
&.alt { background-color: #{gen-custom-prop( $color-primary, 90 )}; }
&.alt-2 { background-color: #{gen-custom-prop( $color-primary, 180 )}; }
&.alt-3 { background-color: #{gen-custom-prop( $color-primary, 270 )}; }
}
&.luma {
&.l00 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 0% ) ) }}
&.l10 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 10% ) ) }}
&.l20 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 20% ) ) }}
&.l30 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 30% ) ) }}
&.l40 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 40% ) ) }}
&.l50 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 50% ) ) }}
&.l60 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 60% ) ) }}
&.l70 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 70% ) ) }}
&.l80 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 80% ) ) }}
&.l90 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 90% ) ) }}
&.l100 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 100% ) ) }}
}
&.chroma {
&.c00 { background-color: #{gen-custom-prop( ( var(--color-hue), 0%, 50% ) ) }}
&.c10 { background-color: #{gen-custom-prop( ( var(--color-hue), 10%, 50% ) ) }}
&.c20 { background-color: #{gen-custom-prop( ( var(--color-hue), 20%, 50% ) ) }}
&.c30 { background-color: #{gen-custom-prop( ( var(--color-hue), 30%, 50% ) ) }}
&.c40 { background-color: #{gen-custom-prop( ( var(--color-hue), 40%, 50% ) ) }}
&.c50 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 50% ) ) }}
&.c60 { background-color: #{gen-custom-prop( ( var(--color-hue), 60%, 50% ) ) }}
&.c70 { background-color: #{gen-custom-prop( ( var(--color-hue), 70%, 50% ) ) }}
&.c80 { background-color: #{gen-custom-prop( ( var(--color-hue), 80%, 50% ) ) }}
&.c90 { background-color: #{gen-custom-prop( ( var(--color-hue), 90%, 50% ) ) }}
&.c100 { background-color: #{gen-custom-prop( ( var(--color-hue), 100%, 50% ) ) }}
}
&.mix {
&.m00 { background-color: #{gen-custom-prop( ( var(--color-hue), 0%, 0% ) ) }}
&.m10 { background-color: #{gen-custom-prop( ( var(--color-hue), 10%, 10% ) ) }}
&.m20 { background-color: #{gen-custom-prop( ( var(--color-hue), 20%, 20% ) ) }}
&.m30 { background-color: #{gen-custom-prop( ( var(--color-hue), 30%, 30% ) ) }}
&.m40 { background-color: #{gen-custom-prop( ( var(--color-hue), 40%, 40% ) ) }}
&.m50 { background-color: #{gen-custom-prop( ( var(--color-hue), 50%, 50% ) ) }}
&.m60 { background-color: #{gen-custom-prop( ( var(--color-hue), 60%, 60% ) ) }}
&.m70 { background-color: #{gen-custom-prop( ( var(--color-hue), 70%, 70% ) ) }}
&.m80 { background-color: #{gen-custom-prop( ( var(--color-hue), 80%, 80% ) ) }}
&.m90 { background-color: #{gen-custom-prop( ( var(--color-hue), 90%, 90% ) ) }}
&.m100 { background-color: #{gen-custom-prop( ( var(--color-hue), 100%, 100% ) ) }}
}
display: block;
float: left;
width: $size;
height: $size;
line-height: $size;
text-align: center;
font-size: $size * .5;
padding: 0;
margin: $size * .1;
border-radius: $size * .1;
border: $size * .05 solid #{gen-custom-prop( (0,0%,var(--color-luma-white)), false, false, false, 50% )};
h3 + & {
clear: left;
}
}
Also see: Tab Triggers