cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

              <link href='https://fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'>


<div id="quote">Apply new class to each word after it is split</div>
<button id="splitBtn">split the text into words</button>
<div id="instructions">Inspect the element's above to see how the new classes have been applied to each word</div>

  font-family: Asap, Arial, Helvetica, sans-serif;
  background:black url(https://s.cdpn.io/16327/texture_bg.jpg) no-repeat 50% 0px;
  margin:5% 10% 0 10%;

  margin:20px 0;

#nav {

  text-transform: uppercase

#instructions {
See https://www.greensock.com/splittext/ for details. 
This demo uses SplitText which is a membership benefit of Club GreenSock, https://www.greensock.com/club/
var split;

document.getElementById("splitBtn").onclick = function() {
  split = new SplitText("#quote", {type:"words", wordsClass:"word word++"});
  TweenLite.from("#instructions", 0.4, {autoAlpha:0});


After the text is spit each word will be wrapped in a div that has the .word class applied which turns the text green.
In addition an incremented word class will be added like .word1, .word2, .word3 etc.

View your browser's Dev Tools / Debugger to see modified DOM 

  <div style="position:relative;display:inline-block;" class="word word1">Apply</div>
  <div style="position:relative;display:inline-block;" class="word word2">new</div>
  <div style="position:relative;display:inline-block;" class="word word3">class</div>
  <div style="position:relative;display:inline-block;" class="word word4">to</div>
You can optionally use charsClass and linesClass  

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................