Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

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.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


<html lang="en">
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>CSS Variables Demo</title>
	<p class="wildCodeSchool"><span class="wild">Wild </span><span class="code">Code </span><span class="school">School</span>
	<div class="messageBox">
		<p class="message">
			Hello <span>Wilders</span>!
	<div class="modifier">
		<form id="main">
			<label for="redCursor" class="redish">Red</label><br>
			<input type="range" min="0" max="255" value="245" name="redCursor" class="cursor1"><br>
			<label for="greenCursor" class="greenish">Green</label><br>
			<input type="range" min="0" max="255" value="100" name="greenCursor" class="cursor2"><br>
			<label for="blueCursor" class="blueish">Blue</label><br>
			<input type="range" min="0" max="255" value="20"name="blueCursor" class="cursor3">


/* I declare my css variables here. */
:root {
	/*the first three are "simple" ones as opposed to "compound" ones*/
  	--red: 125;
		--green: 125;
		--blue: 255; 
	/* and the following two are compound ones: */
		--mainColor: var(--red), var(--green), var(--blue); 
		--secondaryColor: var(--blue), var(--red), var(--green);	
	/* you can think of other ways to compose your secondary colors; like adding or substracting 10 to the JS values...*/

/* So you can use a variables on different sorts of attributes. 
Here I'll use var(--mainColor):
on a linear gradient, 
on a border, 
on a font-color'*/

body {
		background: linear-gradient(to bottom left, rgba(var(--mainColor), 0.5),rgba(var(--secondaryColor), 0.5));
		background-repeat: no-repeat;
		background-attachment: fixed;

.messageBox {	
	border: 10px solid rgb(var(--mainColor));
	width: 50%;
	margin: auto;
	margin-top: 70px;
	margin-bottom: 30px;
	overflow: hidden;

.message {
	color: rgb(var(--secondaryColor));
	font-size: 5rem;
	padding: 0 5% 0 5%;
	text-align: center;

.message span {
	color: rgba(var(--mainColor));

.wildCodeSchool {
	text-align: center;
	font-size: 3em;

.wild {
	color: rgb(var(--red), 0, 0);

.code {
	color: rgb(0, var(--green), 0);

.school {
	color: rgb(0, 0, var(--blue));

.modifier {
	font-size: 1.5em;
	margin: auto;	
	text-align: left;
	width: 50%;

.redish {
	color: rgb(var(--red), 0, 0);

.greenish {
	color: rgb(0, var(--green), 0);

.blueish {
	color: rgb(0, 0, var(--blue));

@media  (max-width: 768px){	
	.message {
		font-size: 2.5em;

	.modifier {
		border: 5px solid rgb(var(--secondaryColor));
		color: rgb(var(--mainColor));
		font-size: 0.8em;
		min-width: 186px;



                const root = document.documentElement;
const red = document.querySelector(".cursor1");
red.addEventListener('input', () => getRedValue(event));
const getRedValue = event => {
	let redVal =;'--red', redVal);

const green = document.querySelector(".cursor2");
green.addEventListener('input', () => getGreenValue(event));
const getGreenValue = event => {
	let greenVal =;'--green', greenVal);	

const blue = document.querySelector(".cursor3");
blue.addEventListener('input', () => getBlueValue(event));

const getBlueValue = event => {
	let blueVal =;'--blue', blueVal);

// Many thanks to Ohans Emmanuel! 
// I followed his tuto