Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

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


Auto Save

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.


                <h1>Copy in Clipboard with JavaScript</h1>

<textarea id="to-copy" spellcheck="false">Write something and copy it into your clipboard by clicking in the button below.</textarea>

<button id="copy" type="button">Copy in clipboard<span class="copiedtext" aria-hidden="true">Copied</span></button>

<textarea id="cleared" placeholder="Paste your copied content here. Just to test…"></textarea>

<p>Works on Firefox 41+, Chrome 42+, IE9+, Opera 29+, Safari 10+</p>


                /* Just to play with animations */
.copiedtext {
  position: absolute;
  left: 0; top: 0; right: 0;
  text-align: center;
  opacity: 0;
  transform: translateY(-1em);
  color: #000;
  transition: all .500s;
.copied .copiedtext {
  opacity: 1;
  transform: translateY(-2em);

/* Some Generic styles */
body {
  text-align: center;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
  color: #444;
  line-height: 1.6;
h1 {
  margin: 1.75em auto 1.25em;
button {
  font-size: 1em;
  font-family: "Open Sans", Helvetica, Arial, sans-serif;
textarea {
  display: block;
  width: 300px;
  max-width: 100%;
  height: 75px;
  margin: 2em auto 1.5em;
  background: #F2F2F6;
  border: 1px solid #ddd;
  padding: 10px 15px;
  resize: vertical;
[id="cleared"] {
  margin-top: 4em;
textarea:focus {
  border-color: #8fa423;
button {
  position: relative;
  padding: 8px 20px;
  border: 0;
  font-size: 0.835em;
  text-transform: uppercase;
  letter-spacing: 0.125em;
  font-weight: bold;
  color: #FFF;
  background: #8fa423;
  transition: background .275s;
button:focus {
  background: #74861A;

p {
  margin-top: 3.25em;
  font-size: .825em;
  color: #777;
  font-weight: bold;
  letter-spacing: .01em


                var toCopy  = document.getElementById( 'to-copy' ),
    btnCopy = document.getElementById( 'copy' ),
    paste   = document.getElementById( 'cleared' );

btnCopy.addEventListener( 'click', function(){;
  paste.value = '';
  if ( document.execCommand( 'copy' ) ) {
      btnCopy.classList.add( 'copied' );
      var temp = setInterval( function(){
        btnCopy.classList.remove( 'copied' );
      }, 600 );
  } else { 'document.execCommand went wrong…' )
  return false;
} );