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.


Codepen by -
<div class="equalizer">
   <span class="column" id="purple"></span>
   <span class="column" id="blue"></span>
   <span class="column" id="cyan"></span>
   <span class="column" id="green"></span>
   <span class="column" id="yellow"></span>
   <span class="column" id="orange"></span>
   <span class="column" id="red"></span> 
   <span id="black"></span>
<input type="button" onclick="JavaScript: play();" value="Play" id=button>


                BODY {
  background-color: black;
  margin: 20px auto 20px auto;

.equalizer {
  text-align: center;
  margin: 10px auto;
  width: 380px;

.column {
  display: inline-block;
  width: 40px;
  margin: 5px;

#purple {
  height: 160px;
  background-color: #8800FF;

#blue {
  height: 140px;
  background-color: #0022FF;

#cyan {
  height: 100px;
  background-color: #22FFFF;

#green {
  height: 140px;
  background-color: #00BB00;

#yellow {
  height: 180px;
  background-color: #FFFF00;

#orange {
  height: 70px;
  background-color: #FF6600;

#red {
  height: 200px;
  background-color: #FF0000;

#black {
  display: inline-block;
  height: 240px;
  width: 1px;
  background-color: #000000;


                //A function to return a random number between a min and a max value
function randomNumber(min, max) {
  number =  Math.floor((Math.random()*(max-min))+ min);
  return number;

//Initialise starting values
var purple, blue, cyan, green, yellow, orange, red;
purple = 160;
blue = 140;
cyan = 100;
green = 140;
yellow = 180;
orange = 70;
red = 200;

//To start with the equalizer is paused
var playing=false;

// A Function to change the height of a column more or less randomly
function changeHeight(column, height) {
  if (height>200) height=200;
  if (height<5) height=5; + "px";  
  return height;

//A Function that will be run every 50ms to animate the equalizer
function animate() {
  if (playing) {
    purple = changeHeight(document.getElementById("purple"),purple);     blue = changeHeight(document.getElementById("blue"),blue); 
    cyan = changeHeight(document.getElementById("cyan"),cyan); 
    green = changeHeight(document.getElementById("green"),green); 
    yellow = changeHeight(document.getElementById("yellow"),yellow); 
    orange = changeHeight(document.getElementById("orange"),orange); 
    red = changeHeight(document.getElementById("red"),red); 
    //Repeat this function every 50 ms
    setTimeout(animate, 50);

//A Function to play or pause the animation
function play() {
  if (playing) {
  } else {