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.


                <closable-surface demo>
	<h2>Hello world with a longer title. Check this out, the text will wrap below the close icon.</h2>
	<p>In this example, the content of this surface will not collide with the close button when the surface is resized or content is changed. There is a floating element which causes text to wrap around the corner where the button appears. Then the button is positioned in the corner based on the parent's reference.</p>
	<p>You can remove the <code>demo</code> attribute from the <code>closable-surface</code> element to see the final effect without the blue visualized floating box.</p>


                body {
	font-family: sans-serif;

closable-surface {
	border: 1px solid black;
	border-radius: .5em;

h2 {
	margin: 0;
	font-size: 2em;

code {
	background: #eee;
	padding: 0 2px;


                const html = `
<style type="text/css">
	:host {
		display: block;
		position: relative;
		overflow: hidden;
		max-width: 500px;
		margin: 0 auto;
		--padding: 1rem;
		--button-size: 2em;
		padding: var(--padding);
	span.floater {
		float: right;
		display: block;
		width: calc(var(--button-size) - var(--padding));
		height: calc(var(--button-size) - var(--padding));
		font-size: 1.5em;
	:host([demo]) span.floater {
		background: rgba(0,0,255, .3);
	button {
		position: absolute;
		top: 0;
		right: 0;
		background: rgba(240, 240, 240, 0);
		font: inherit;
		border: 0;
		cursor: pointer;
		display: inline-flex;
		align-items: center;
		justify-content: center;
		aspect-ratio: 1/1;
		width: var(--button-size);
		transition: .218s ease;
	button:hover {
		background: rgba(240, 240, 240, .8);
	<span class="floater">

class ClosableSurface extends HTMLElement {
	constructor() {
		this.attachShadow({ mode: 'open'}).innerHTML = html;

window.customElements.define('closable-surface', ClosableSurface);