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

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

              
                <article role="article" itemscope itemtype="http://schema.org/BlogPosting" class="hentry">
  <header>
  <h1>Moby-Dick;
    <br>or, The Whale</h1>
  </header>
  <div class="entry-content" itemprop="articleBody">
  <p>Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people's hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball. With a philosophical flourish Cato throws himself upon his sword; I quietly take to the ship. There is nothing surprising in this. If they but knew it, almost all men in their degree, some time or other, cherish very nearly the same feelings towards the ocean with me.
<p>There now is your insular city of the Manhattoes, belted round by wharves as Indian isles by coral reefs—commerce surrounds it with her surf. Right and left, the streets take you waterward. Its extreme downtown is the battery, where that noble mole is washed by waves, and cooled by breezes, which a few hours previous were out of sight of land. Look at the crowds of water-gazers there.</p>
 <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/moby-dick.png" alt="Wood engraving of a sperm whale" style="width: 100%">
<p>Circumambulate the city of a dreamy Sabbath afternoon. Go from Corlears Hook to Coenties Slip, and from thence, by Whitehall, northward. What do you see?—Posted like silent sentinels all around the town, stand thousands upon thousands of mortal men fixed in ocean reveries. Some leaning against the spiles; some seated upon the pier-heads; some looking over the bulwarks of ships from China; some high aloft in the rigging, as if striving to get a still better seaward peep. But these are all landsmen; of week days pent up in lath and plaster—tied to counters, nailed to benches, clinched to desks. How then is this? Are the green fields gone? What do they here?
<p>But look! here come more crowds, pacing straight for the water, and seemingly bound for a dive. Strange! Nothing will content them but the extremest limit of the land; loitering under the shady lee of yonder warehouses will not suffice. No. They must get just as nigh the water as they possibly can without falling in. And there they stand—miles of them—leagues. Inlanders all, they come from lanes and alleys, streets and avenues—north, east, south, and west. Yet here they all unite. Tell me, does the magnetic virtue of the needles of the compasses of all those ships attract them thither?
</div>
</article>
              
            
!

CSS

              
                @font-face {
    font-family: 'IM Fell French Canon Pro';
    src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/im-fell-french-canon-pro.woff2') format('woff2'),
         url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/4273/im-fell-french-canon-pro.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}
@keyframes popin {
  to {
   transform: scale(1);
  }
}
article {
  font-family: IM Fell French Canon Pro;
  font-size: 1.4rem;
  line-height: 1.4;
  width: 80%;
  margin-left: 4rem;
  max-width: 50rem;
}
article h1 {
  font-size: 4rem;
}
#timeestimate { font-style: italic; }
              
            
!

JS

              
                function updateTime(decimalTime, wordCount, picCount) {
  var mins = Math.floor(Math.abs(decimalTime)),
    secs = Math.floor((Math.abs(decimalTime) * 60) % 60),
    timeEst = mins + ":" + (secs < 10 ? "0" : "") + secs;
  var timeestimate = document.createElement("p");
timeestimate.id = "timeestimate";
  if (reportMethod == "roundedTime" || reportMethod == "preciseTime") {
  var timeTag = document.createElement("time");
  timeTag.setAttribute("datetime", mins + "m " + secs + "s");
    if (reportMethod == "roundedTime") {
  timeTag.innerHTML = (decimalTime > 0.5 ? Math.round(decimalTime) + " min" : secs + " secs");
    } else {
      timeTag.innerHTML = mins + ":" + (secs < 10 ? "0" : "") + secs;
    }
  timeestimate.appendChild(timeTag);
  timeestimate.innerHTML += " to read";
  }
 if (reportMethod == "wordCount") {
   timeestimate.innerHTML = "Article length: "+wordCount+" words";
   if (picCount > 0) {
     timeestimate.innerHTML += ", "+picCount+" figure"+(picCount > 1 ? "s" : "");    
   }
 } articleText.insertBefore(timeestimate, articleText.firstChild);
}

function addEmUp(element) {
  var checkTag = articleText.getElementsByTagName(element);
  for (var i = 0; i < checkTag.length; i++) {
    wordCount = checkTag[i].innerHTML.split(' ').length;
    totalCount = totalCount + wordCount;
  }
}

function estimateTime() {
  elementsToCount.forEach(addEmUp);
  var pictures = articleText.getElementsByTagName("img");
  completeCount = totalCount + (pictures.length * ((wpm / 60) * secsPerPic));
  updateTime(completeCount / wpm, totalCount, pictures.length);
}
var wpm = 200,
  elementsToCount = ["p", "li", "dd"],
  secsPerPic = 5,
  wordCount = 0,
  totalCount = 0,
  reportMethod = "roundedTime";
  // options are: roundedTime ("2 min to read", preciseTime ("00:45 to read"), and wordCount "Article length: 800 words, 2 figures")
  articleText = document.getElementsByClassName("entry-content")[0];
estimateTime();
              
            
!
999px

Console