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.


                <body id="randomColorMe">


                body {
    height: 100vh;


Based on code from Nicholas Fazzolari

Generates a pseudorandom hexadecimal color value and sets it to
the background color of the body element.

"use strict";

let bodyEl = document.getElementById("randomColorMe");
bodyEl.addEventListener("click", setBackgroundColor);

function generateRandomHexColor() {
    // Step 1: Generate three random numbers between 0 and 1
    const randomValues = [Math.random(), Math.random(), Math.random()]
    // Step 2: Convert random numbers into 0-255 range
    const integerColors = => Math.floor(r * 256))
    // Step 3: Convert integers into hex strings
    const hexColors = => intColor.toString(16))
    // Step 4: Add zero at the start of each hex string and then take last two characters
    // this will effectively zero pad values that have only one number
    // Example 1: 5 -> 05 -> 05
    // Example 2: A3 -> 0A3 -> A3
    const paddedHexColors = => `0${hexColor}`.slice(-2))
    // Step 5: Join all the numbers into a single string
    const hexCode = paddedHexColors.join('')
    // Step 6: Add # at the start
    return `#${hexCode}`

function setBackgroundColor() {
    let randomColor = generateRandomHexColor(); = randomColor;