Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="article-content">

  <h3>Lorem ipsum dolor sit amet.</h3>
  <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas temporibus impedit, qui doloribus eos deleniti commodi accusantium vel quibusdam neque ducimus, laudantium tempora iure ullam obcaecati deserunt ipsam pariatur incidunt.</p>
  <h3>Ducimus deserunt amet aliquid laudantium.</h3>
  <p>Eligendi eum neque ipsa voluptate ipsam necessitatibus? Nemo, quis esse voluptatem obcaecati tempore natus? Vel inventore nisi explicabo facilis, autem mollitia earum eos velit quae et adipisci, quos perspiciatis ipsam.</p>
  <h3>Laudantium architecto provident porro sunt.</h3>
  <p>Harum nihil ut dignissimos sed earum, tempore atque praesentium quisquam aperiam cupiditate dolor. Iusto blanditiis neque cupiditate illo perferendis et est vero praesentium enim vitae voluptatem, itaque qui eum obcaecati.</p>

</div>
              
            
!

CSS

              
                body {
  max-width: 500px;
  margin: 1rem auto;
  padding: 2rem;
  font: 300 100%/1.6 system-ui;
}

h3 a {
  margin-right: 0.2rem;
}

              
            
!

JS

              
                const $headers = $(".article-content > h3");

$headers.each((i, el) => {
  const $el = $(el);

  // skip it if it already has a link inside
  if ($el.has("a").length != 0) {
    return;
  }

  let idToLink = "";

  // skip it if it already has an id
  if ($el.attr("id") === undefined) {
    // give it ID to match
    idToLink = "article-header-id-" + i;
    $el.attr("id", idToLink);
  } else {
    // make sure the ID matches
    idToLink = $el.attr("id");
  }

  // append a little linky #
  const $headerLink = $("<a />", {
    html: "#",
    class: "article-headline-link",
    href: "#" + idToLink
  });
  $el.addClass("has-header-link").prepend($headerLink);
});

              
            
!
999px

Console