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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

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


    Select text. The client rectangles of the Range will be highlighted.
    Triple click on a word in this paragraph. Notice how Chrome creates an extra client rectangle in the selection range.

    "Are we rising again?" "No. On the contrary." "Are we descending?" "Worse than that, captain! we are falling!" "For Heaven's sake heave out the ballast!" "There! the last sack is empty!" "Does the balloon rise?" "No!" "I hear a noise like the dashing
    of waves. The sea is below the car! It cannot be more than 500 feet from us!" "Overboard with every weight! ... everything!"
    Such were the loud and startling words which resounded through the air, above the vast watery desert of the Pacific, about four o'clock in the evening of the 23rd of March, 1865.

<h3>The selection start and end could be...</h3>

<div class="article">
  <h4>... in different parents.</h4>
    Few can possibly have forgotten the terrible storm from the northeast, in the middle of the equinox of that year. The tempest raged without intermission from the 18th to the 26th of March. Its ravages were terrible in America, Europe, and Asia, covering
    a distance of eighteen hundred miles, and extending obliquely to the equator from the thirty-fifth north parallel to the fortieth south parallel. Towns were overthrown, forests uprooted, coasts devastated by the mountains of water which were precipitated
    on them, vessels cast on the shore, which the published accounts numbered by hundreds, whole districts leveled by waterspouts which destroyed everything they passed over, several thousand people crushed on land or drowned at sea; such were the traces
    of its fury, left by this devastating tempest. It surpassed in disasters those which so frightfully ravaged Havana and Guadalupe, one on the 25th of October, 1810, the other on the 26th of July, 1825.


                .debug {
  position: absolute;
  border: 1px solid red;
  z-index: -1;
.debug:before {
  position: relative;
  background: lightblue;
  top: -1em;
  left: 50%;
  content: attr(data-index)



 * Create an absolutely-position element
 * @param clientRect
 * @param {boolean} [addScroll=false] Whether to add[XY]Offset
 * @returns {Element}
function createAbsoluteElement(clientRect, addScroll) {
  var span = document.createElement('span'); = + (addScroll ? window.pageYOffset : 0) + 'px'; = clientRect.left + (addScroll ? window.pageXOffset : 0) + 'px'; = clientRect.width + 'px'; = clientRect.height + 'px';
  span.className = 'debug';
  return span;

document.addEventListener('mouseup', function (event) {
  var sel = window.getSelection();
  if (sel.rangeCount) {
    // highlight the client rects in the range
    var range = sel.getRangeAt(0);
    var rectangles = range.getClientRects();  //
    if (window.getSelection().toString()) {

      // cleanup
      var nodes = document.querySelectorAll('.debug');
      for (var i = 0; i < nodes.length; ++i) {
      var span;
      for (i = 0; i < rectangles.length; i++) {
        span = createAbsoluteElement(rectangles[i]);
        span.setAttribute('data-index', i);
      // highlight the last clientRect = 'yellow';