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>Preventing paste into an input field</h1>
<p>This example demonstrates how to stop a user from pasting content into a HTML input form field using JavaScript. Check the HTML and JavaScript panes for more details or scroll to the bottom to find a code example.</p>

<div><label for="paste-ok">✅ You can paste in this field as normal</label></div>
<div><input type="text" id="paste-ok" /></div>

<div><label for="paste-no">🛑 You can't paste in this field: this uses the attribute <code>onpaste</code></label></div>
<div><input type="text" id="paste-no" onpaste="return false" />

<div><label for="paste-no-event">🛑 You can't paste in this field either: this uses an event listener attached to the input field</label></div>
<div><input type="text" id="paste-no-event" />

<p>📌 Works in modern browsers. The paste event is part of the Clipboard API. Check out the <a href="">caniuse stats</a>.</p>

<h2>Code Example</h2>
<pre><code>&lt;input type="text" id="paste-no-event" /&gt;
  const pasteBox = document.getElementById("paste-no-event");
  pasteBox.onpaste = e => {
    return false;


                body {
  font-family: "Open Sans", sans-serif;
  font-size: 18px;
  max-width: 1200px;
  margin: 0 auto;

input {
  height: 35px;
  width: 250px;
  border-radius: 10px;
  border: 1px solid black;
  font-size: 18px;
  padding: 3px;
  margin: 15px 0;

pre {
  background-color: #afafaf;
  padding: 20px;
  display: inline-block;



                const pasteBox = document.getElementById("paste-no-event");
pasteBox.onpaste = (e) => {
  return false;

// Alternative syntax:

// pasteBox.addEventListener('paste', e => {
//   e.preventDefault();
//   return false;
// });