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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

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


Add Packages

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.


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.


                <p>Reload to see another random color</p>
<div id="colors"></div>


                body {
	margin: 0 auto;
	max-width: 40em;
	width: 88%;

#colors {
	height: 12em;
	width: 100%;


 * Create a random color value.
 * (c) 2021 Chris Ferdinandi, MIT License,
 * @return {String} A random six-digit color hexcode
function createColor () {

	// The available hex options
	let hex = ['a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];

	 * Randomly shuffle an array
	let shuffle = function () {

		let currentIndex = hex.length;
		let temporaryValue, randomIndex;

		// While there remain elements to shuffle...
		while (0 !== currentIndex) {
			// Pick a remaining element...
			randomIndex = Math.floor(Math.random() * currentIndex);
			currentIndex -= 1;

			// And swap it with the current element.
			temporaryValue = hex[currentIndex];
			hex[currentIndex] = hex[randomIndex];
			hex[randomIndex] = temporaryValue;


	 * Create a six-digit hex color
	let hexColor = function () {

		// Create the color
		let color = '#';

		// Shuffle the hex values and append
		for (let i = 0; i < 6; i++) {
			color += hex[0];

		return color;


	// Return the color string
	return hexColor();


// Set the background-color of the #colors element to a random color
let app = document.querySelector('#colors'); = createColor();