Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ 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.


                <div class="div">
  <div class="num"></div>
  <button>Change color</br></button>




 font-family: Montserrat, sans-serif;
 background-image: url('data:image/svg+xml,%3Csvg xmlns="" width="28" height="49" viewBox="0 0 28 49"%3E%3Cg fill-rule="evenodd"%3E%3Cg id="hexagons" fill="%239C92AC" fill-opacity="0.4" fill-rule="nonzero"%3E%3Cpath d="M13.99 9.25l13 7.5v15l-13 7.5L1 31.75v-15l12.99-7.5zM3 17.9v12.7l10.99 6.34 11-6.35V17.9l-11-6.34L3 17.9zM0 15l12.98-7.5V0h-2v6.35L0 12.69v2.3zm0 18.5L12.98 41v8h-2v-6.85L0 35.81v-2.3zM15 0v7.5L27.99 15H28v-2.31h-.01L17 6.35V0h-2zm0 49v-8l12.99-7.5H28v2.31h-.01L17 42.15V49h-2z"/%3E%3C/g%3E%3C/g%3E%3C/svg%3E');
  margin: 0;
  padding: 0;
.div {
  height: 100vh;
  width: 100vw;
  position: relative;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    padding: 20px;
    text-shadow: 1px 1px black;

button {
    font-size: 1.5rem;
    font-weight: bold;
    text-shadow: 1px 1px 2px white;
    background: white;
    height: 100px;
    width: 200px;
    display: inline-block;
    position: absolute;
    top: 50%;
    margin-top: -50px;
    left: 50%;
    margin-left: -100px;


                const btn = document.querySelector('button'),
      div = document.querySelector('.div'),
      num = document.querySelector('.num');

function changeColor() { = '#'+ Math.round(Math.random()*1000000);
num.innerHTML = 'background-color: ' + + ";";

  btn.addEventListener('click', changeColor);