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.


                <div class="wrap">
  <h2>A Simple One-line Code Highlighter</h2>
  <p>The box below demonstrates how you might implement a live code highlighter in a live editor. This example demonstrates live highlighting of a quoted string.</p>
  <div id="container" class="container">Some example text.</div>
  <p>Type in some text surrounded by double quotes (e.g. "javascript")</p>
  <p>Original code and idea by <a href="">Erik Kückelheim</a> creator of <a href="">JSchallenger</a>. Read about this code in <a href="">Issue #375 of Web Tools Weekly</a></p>


                body {
  font-family: Arial, Helvetica, sans-serif;
  padding: 0 20px;
  font-size: 1.2em;

a {
  color: firebrick;

.wrap {
  max-width: 800px;
  margin: 0 auto;

.container {
  background-color: #1a202c;
  padding: 12px 10px;
  border-radius: 10px;
  color: white;
  font-size: 16px;
  font-family: monospace;
  min-height: 20px;
  line-height: 1.4;
  white-space: pre;

.container:focus {
  outline: none;



                const container = document.getElementById("container");

container.setAttribute("contenteditable", "true");

let timeout;
const debounce = (func, wait) => {
  timeout = setTimeout(func, wait);

const format = () => {
  let text = container.innerText;
  text = text.replace(/"(.*?)"/g, (match) => {
    return `<span style='color:orange'>${match}</span>`;
  container.innerHTML = text;

const setCaret = () => {
  let node = container.lastChild;
  if (node) {
    const sel = window.getSelection();
    while (node.nodeType === 1 && node.childNodes.length > 0) {
      node = node.lastChild;
    sel.collapse(node, node.length);
const handleInput = () => {
  debounce(() => {
  }, 200);

container.addEventListener("input", handleInput);