Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <p id="thisOne">Some random contents</p>
<p id="thisToo" class="anicol">Some other random contents</p>

<!-- (X) VISIT CODE-BOXX -->
<div id="code-boxx">
  Visit
  <a href="https://code-boxx.com/create-rainbow-text-pure-css-js"
     target="_blank">
    Code Boxx
  </a> for more details.
</div>
              
            
!

CSS

              
                /* (A) WE CAN USE CSS TO ADD TRANSITION EFFECT */
.anicol { transition: color ease 0.5s; }


/* (X) DOES NOT MATTER */
/* PAGE & BODY */
* {
  font-family: arial, sans-serif;
  box-sizing: border-box;
}
body {
  min-height: 100vh;
  background-image: url(https://images.unsplash.com/photo-1502847427791-d0194ec4cff4?crop=entropy&cs=srgb&fm=jpg&ixid=MnwxNDU4OXwwfDF8cmFuZG9tfHx8fHx8fHx8MTY0MTgxODk2Mw&ixlib=rb-1.2.1&q=85);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  text-align: center;
}
#thisOne, #thisToo { font-size: 40px; }

/* FOOTER */
#code-boxx {
  font-weight: 600;
  margin-top: 30px;
  color: #fff;
}
#code-boxx a {
  display: inline-block;
  padding: 5px;
  text-decoration: none;
  background: #b90a0a;
  color: #fff;
}
              
            
!

JS

              
                var rainbow = {
  // (A) SETTINGS
  // preset colors
  colors : ["fc0303", "45f52a", "2a7bf5", "2af5e4", "c92af5", "f5dd2a", "66655d"],
  // animation speed
  pause: 1000,
  // holder for all rainbow elements
  target : {}, 
 
  // (B) INITIALIZE RAINBOW EFFECT
  // el : ID of target element
  init : function (el) {
    rainbow.target[el] = {
      now : -1,
      timer : setInterval(function () {
        rainbow.run(el);
      }, rainbow.pause)
    };
  },
 
  // (C) UPDATE COLOR OF TARGET ELEMENT
  // el : ID of target element
  run : function (el) {
    rainbow.target[el].now++;
    if (rainbow.target[el].now >= rainbow.colors.length) { rainbow.target[el].now = 0; }
    document.getElementById(el).style.color = "#" + rainbow.colors[rainbow.target[el].now] ;
  }
};
 
// (D) ATTACH RAINBOW EFFECT ON PAGE LOAD
window.addEventListener("load", function () {
  rainbow.init("thisOne");
  rainbow.init("thisToo");
});
              
            
!
999px

Console