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.


We're using the "rel" (relative) attribute to relate this element to a JavaScript actions vs. using a .class or #id so that you know it's for JS specifically 

PE personal preference:

<button rel='toggle'>Toggle menu</button>

<nav class='menu'>
	<a href='#'>Thing one</a>
	<a href='#'>Thing two</a>
	<a href='#'>Thing three</a>

	<button rel='toggle'>Close menu</button>



.menu {
	display: none;
	/* not a best practice - but fine for this example - (at this time) */

/* We're changing the class on a larger parent scope vs. just the menu... because we may need to style many things on the page differently in this state (menu "open" state) */ {
	/* */
} .menu { /* how the menu should behave _visually_ (when open) */
	display: block; /* show it! (not "none") */
	/* */
	position: fixed; /* cover the whole screen */
	top: 0;
	left: 0;
	width: 100%;
	height: 100vh;
	/* */
	display: flex; /* positioning its items */
	flex-direction: column;
	justify-content: center;
	align-items: center;
	/* */
	background-color: var(--pe-cyan);

body {
	padding: 20px;

.menu a {
	display: block;
	text-transform: uppercase;
	text-decoration: none;
	font-family: sans-serif;
	padding: 10px;

.menu button {
	margin-top: 20px;



var body = document.querySelector('body');

// add a listener to the whole body!
body.addEventListener('click', function(event) {

	// if the click happens on the toggle button...
	if ('[rel="toggle"]') ) {


this style of setting the even in a larger scope 
and then based on what is clicked -
	is called "event delegation"