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.


                <div class="container">
  <h2>Accessing the Clipboard using execCommand()</h2>
  <p id="content-copy">This text will be inserted into the clipboard.</p>
  <button id="button-copy">Copy Text</button>
  <input id="content-cut" type="text" value="This text will be cut, then inserted into the clipboard." />
  <button id="button-cut">Cut Text</button>
  <textarea placeholder="Press Ctrl + V to paste the clipboard's current content." rows="10"></textarea>




                document.addEventListener("DOMContentLoaded", () => {
  const $ = document.querySelector.bind(document);
  const contentCopyElm = $("#content-copy"),
        inputCutElm = $("#content-cut"),
        buttonCopyElm = $("#button-copy"),
        buttonCutElm = $("#button-cut");
  const isSupported = (cmd) => {
    return document.queryCommandSupported(cmd);
  buttonCopyElm.addEventListener("click", () => {
    // We will need a range object and a selection.
    const range = document.createRange(),
          selection = window.getSelection();

    // Clear selection from any previous data.

    // Make the range select the entire content of the element.

    // Add that range to the selection.

    // Try to copy the selection to the clipboard.
    try {
      if(isSupported("copy")) document.execCommand("copy");
      else alert(`execCommand("copy") is not supported in your browser.`);
    } catch(e) {
    // Clear selection if you want to.
  buttonCutElm.addEventListener("click", () => {
    // Select the content of the input;
    // Try to cut the content of the input
    try {
      if (isSupported("cut")) document.execCommand("cut");
      else alert(`execCommand("cut") is not supported in your browser.`);
    } catch(e) {