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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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>Experiments with Sass Color Functions</h1>
<p>Top and bottom border to all divs are generated with <code>grayscale($color)</code> and <code>desaturate($color, 20)</code>, respectively.</p>
<h2>Sass Native:</h2>
<div class="darken">
<pre>darken($color, 20);</pre>
<p>Darken base color by 20%.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#darken-instance_method">Documentation.</a> Related: <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#lighten-instance_method">lighten</a></p>
</div>
<div class="complement">
<pre>complement($color);</pre>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#complement-instance_method">Documentation.</a></p>
</div>
<div class="saturate">
<pre>saturate($color, 20);</pre>
<p>Increase saturation of base color by 20%.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#saturate-instance_method">Documentation</a>. Related: <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#desaturate-instance_method">desaturate</a></p>
</div>
<div class="invert">
<pre>invert($color);</pre>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#invert-instance_method">Documentation.</a></p>
</div>
<div class="mix">
<pre>mix($color, #00F, 75%);</pre>
<p>Mix blue into the base color by 75%.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#mix-instance_method">Documentation.</a></p>
</div>
<div class="hue">
<pre>adjust_hue($color, 110);</pre>
<p>Rotate base color by 110 degrees around the color wheel.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#adjust_hue-instance_method">Documentation</a></p>
</div>
<div class="adjust-single">
<pre>adjust-color($color, $green: 128);</pre>
<p>Add a hue to a color, by value. Use a negative number to subtract a color.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#adjust_color-instance_method">Documentation.</a> Related: <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#scale_color-instance_method">scale-color</a>, <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#change_color-instance_method">change-color</a></p>
</div>
<div class="adjust-multiple">
<pre>adjust-color($color, $green: -64, $blue: -64)</pre>
<p>Remove multiple hues from a color, by value. Use a positve number to add a hue.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#adjust_color-instance_method">Documentation.</a></p>
</div>
<div class="transparentize">
<pre>transparentize(gray, .5);</pre>
<p>Adjust the transparency (alpha) of a color.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#transparentize-instance_method">Documentation.</a> Related: <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#fade_out-instance_method">fade-out</a>, <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#opacify-instance_method">opacify</a>, <a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#transparentize-instance_method">transparentize</a></p>
</div>
<div class="red">
<pre>rgb(red($color), 0, 0)</pre>
<p>Use only the amount of red in the base color.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#red-instance_method">Documentation.</a></p>
</div>
<div class="green">
<pre>rgb(0, green($color), 0);</pre>
<p>Use only the amount of green in the base color.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#green-instance_method">Documentation.</a></p>
</div>
<div class="blue">
<pre>rgb(0, 0, blue($color));</pre>
<p>Use only the amount of blue in the base color.</p>
<p class="docs"><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#blue-instance_method">Documentation.</a></p>
</div>
<p>Also see color "getter" functions:</p>
<ul>
<li><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#hue-instance_method">hue($color)</a></li>
<li><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#saturation-instance_method">saturation($color)</a></li>
<li><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#lightness-instance_method">lightness($color)</a></li>
<li><a href="http://sass-lang.com/documentation/Sass/Script/Functions.html#alpha-instance_method">alpha($color)</a></li>
</ul>
<h2>Compass:</h2>
<div class="shade">
<pre>shade($color, 50%);</pre>
<p>Mix <code>$color</code> with black, by %.</p>
<p class="docs"><a href="http://compass-style.org/reference/compass/helpers/colors/#shade">Documentation.</a> Related: <a href="http://compass-style.org/reference/compass/helpers/colors/#tint">tint</a></p>
</div>
@import "compass/css3";
$color: #C6538C; // Sass Pink
/* Other interesting / enlightening color values
$color: #C6538C; // Sass Pink
$color: #bada55;
$color: #cab1e5;
$color: #c0ffee;
$color: blueviolet;
$color: goldenrod;
$color: darkturquoise;
*/
body {
background-color: $color;
}
.darken {
background-color: darken($color, 20);
}
.complement {
background-color: complement($color);
}
.saturate {
background-color: saturate($color, 20);
}
.invert {
background-color: invert($color);
}
.mix {
background-color: mix($color, #00F, 75%);
}
.hue {
background-color: adjust_hue($color, 110);
}
.adjust-single {
background-color: adjust-color($color, $green: 128);
}
.adjust-multiple {
background-color: adjust-color($color, $green: -64, $blue: -64);
}
.transparentize {
background-color: transparentize(gray, .5);
}
.red {
background-color: rgb(red($color), 0, 0);
}
.green {
background-color: rgb(0, green($color), 0);
}
.blue {
background-color: rgb(0, 0, blue($color));
}
.shade {
background-color: shade($color, 50%);
}
div {
color: white;
border-top: solid grayscale($color) 5px;
border-bottom: solid desaturate($color, 20) 5px;
font-weight: bold;
width: 46%;
padding: 1%;
margin: 1%;
float: left;
&:nth-child(2n) { clear:left; }
pre { font-size: large; margin: .5rem; }
p { margin: .5rem;
&.docs {font-weight: normal;}
}
}
p { clear: both; }
Also see: Tab Triggers