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 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="post">
  <div class="container">
  <h2>Calculating Color: Dynamic Color Theming with Pure CSS</h2>
  <p class="desc">Did you know that you can build custom dynamic color themes without the use of JavaScript or a CSS preprocessor!? Read on!</p>
  <div class="meta">
    <div class="date">December 5, 2019</div>


                @import url(';1&family=Montserrat:wght@500&display=swap');

* {
  box-sizing: border-box;

body {
  display: flex;
  height: 100vh;
  width: 100vw;
  justify-content: center;
  align-items: center;

.post {
  --color1: #fa744f;
  --color2: #dab8f3;
  font-family: 'Amiri';
  width: 380px;
  height: 320px;
  padding: 2rem;
  text-align: center;
  display: flex;
  background: linear-gradient(var(--color1) 40%, var(--color2) 60%);

.container {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: white;

h2 {
  font-family: 'Montserrat', serif;
  font-size: 1.4rem;
  line-height: 1.2;

.desc {
  text-align: left;

.meta {
  font-style: italic;
  font-size: 0.8;



                // Color Palette
const colorPalette = ['#fa744f', '#ffbcbc', '#4cd3c2', '#b7efcd', '#edffea', '#ffe75e', '#feb72b', '#e85f99', '#9399ff', '#dab8f3', '#ea7ad7', '#ce0f3d', '#fd2eb3', '#ffc6c7']

// Select 1st color
const color1 = colorPalette[Math.floor(Math.random() * colorPalette.length)];

// Remove 1st color from list of possibilities
const remainingColors = colorPalette.filter(function(val){ return val !== color1 })

// Select 2nd color
const color2 = remainingColors[Math.floor(Math.random() * remainingColors.length)];

// Set color values on the element
document.querySelector('.post').style.setProperty('--color1', color1)
document.querySelector('.post').style.setProperty('--color2', color2)