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

              
                <main>
	<h1>Different ways to call (or not call) <code>classList.remove()</code></h1>
	<p>Each of these boxes starts with 3 classes defining different background colors. If our call to <code>classList.remove()</code> works, it should fall back to a simple gray color. Otherwise, it will either display yellow, green, or blue.</p>
	<p>Open your DevTools to see how each either succeeds or fails depending on the syntax and browser.</p>

	<h2>Fails because "invalid characters"</h2>
	<code><pre>// 😭 "Invalid characters" / can't include spaces
thing1.classList.remove('class1 class2 class3');</pre></code>
	<div id="thing1" class="class1 class2 class3"></div>

	<h2>Works in modern browsers (not IE)</h2>
	<code><pre>// 😎 Modern
thing2.classList.remove('class1', 'class2', 'class3');</pre></code>
	<p class="warning"><strong>Warning</strong>: Doesn't work in Internet Explorer.</p>
	<div id="thing2" class="class1 class2 class3"></div>

	<h2>Works in Internet Explorer</h2>
	<code><pre>// 🤓 Internet Explorer
thing3.classList.remove('class1');
thing3.classList.remove('class2');
thing3.classList.remove('class3');</pre></code>
	<div id="thing3" class="class1 class2 class3"></div>
	
	<h2>References</h2>
	<ul>
		<li><a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/classList#Browser_compatibility" target="_blank" rel="noopener">MDN: Element.classList</a></li>
	</ul>
</main>

              
            
!

CSS

              
                /* ------------------------------ */
/* Base                           */
/* ------------------------------ */

html {
	box-sizing: border-box;
}

*,
::after,
::before {
	box-sizing: inherit;
}

body {
	margin: 1rem auto 3rem;
	line-height: 1.4;
	tab-size: 4;
}

main {
	display: block; /* Fix IE rendering main as inline */
	margin: 0 auto;
	max-width: 38rem;
	padding-left: 1rem;
	padding-right: 1rem;
}

pre {
	border: 1px solid #ccc;
	padding: 1rem;
	overflow: auto;
	-webkit-overflow-scroll: touch;
}

.warning {
	color: red;
	font-size: 0.8rem;
}

/* ------------------------------ */
/* Demo                           */
/* ------------------------------ */

div { width: 100px; height: 100px; }
div { background: gray; }

.class1 { background: yellow; }
.class2 { background: green; }
.class1 { background: blue; }

              
            
!

JS

              
                // 😭 "Invalid characters" / can't include spaces
try {
	thing1.classList.remove('class1 class2 class3');
} catch (err) {
	console.log(err);
}

// 😎 Modern
thing2.classList.remove('class1', 'class2', 'class3');

// 🤓 Internet Explorer
thing3.classList.remove('class1');
thing3.classList.remove('class2');
thing3.classList.remove('class3');

              
            
!
999px

Console