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

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.

HTML

              
                <section class="content">
  <p>Often, the thud of mail through the front door is met with a sigh. If it isn’t an electricity bill, it’s a once-in-a-lifetime promotion from a discount furniture store or a flyer from the local pizza place<span class='footnote'>Another footnote</span>. The online world—with its minefield of political fearmongering, spam links and jealousy-inducing vacation photos from acquaintances—doesn’t offer much more<span class='footnote'>Footnote 1</span>. Has the age of meaningful correspondence come to an end? And if so, what have we lost along the way?</p>
  <p>The digital age has reformed both the way that we correspond and the means through which we can view others’ correspondence<span class='footnote'>Once more, with feeling</span>. With letters, we are permitted unregulated access into the inner musings and fluctuating emotions of the author. And because of their sentimental sway they are usually lugged from one home to the next, all the great hopes and heartaches of a lifetime collected in a shoebox and stashed under the eaves. Emails, however, are password protected, guarded by privacy laws and unlikely to be found in an attic. Even if people did consciously donate their digital archives, these exchanges lack the same emotional resonance.</p>
</div>
              
            
!

CSS

              
                body {
  width: 80%;
  margin: 0 auto;
}

.footnote {
  color: red;
}

sup {
  color: blue;
}

a {
  color: black;
  text-decoration: none;
}
              
            
!

JS

              
                /*
  1. Hide all the elements with class footnotes
  2. Add a number corresponding to the number of the footnote
    * If possible make it a hyperlink
  3. Create an ordered list
  4. Create a link for each footnote pointing to the footnote number
  
*/

const fnArray = document.querySelectorAll('.footnote');

fnArray.forEach(function(elem, i) {
  let reference = document.createElement('sup');
  reference.setAttribute('id', (i+1)) // id is the target for the link
  let link = document.createElement('a');
  link.setAttribute('href', '#fn' + (i+1));
  link.innerText = (i+1);
  reference.appendChild(link);
  elem.insertAdjacentElement('afterend', reference); // 2
  elem.style.display = 'none'; // 1
})

const hr = document.createElement('hr');
document.documentElement.appendChild(hr);
const ol = document.createElement('ol'); // 3
document.documentElement.appendChild(ol);
fnArray.forEach(function(elem, i) {
  let item = document.createElement('li');
  item.setAttribute('id', 'fn' + (i+1))// 4
  let link = document.createElement('a');
  link.setAttribute('href', '#' + (i+1));
  link.innerText = elem.textContent;
  
  item.appendChild(link);
  ol.appendChild(item);
})

              
            
!
999px

Console