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

              
                <div id="demo">
	<p>Instructions: change your OS light/dark color-scheme.</p>
	<p>Depending on the setting, the <code>font-size</code>, <code>border-style</code>, <code>font-weight</code>, etc. will change thanks to the custom <code>--light-dark()</code> function.</p>
	<p>The text color and <code>background-color</code> also change, thanks to the built-in <code>light-dark()</code></p>
</div>

<div class="warning"><p>This is a demo for <a href="https://brm.us/css-custom-functions" target="_top">https://brm.us/css-custom-functions</a>. It relies on <a href="https://drafts.csswg.org/css-mixins/" target="_top">Custom Functions in CSS</a>. Try it in Chrome Canary with Experimental Web Platform Features enabled.</p></div>
              
            
!

CSS

              
                @function --light-dark(--light, --dark) {
	result: var(--light);
	
	@media (prefers-color-scheme: dark) {
		result: var(--dark);
	}
}

#demo {
	width: 60ch;
	text-align: center;
	text-wrap: balance;
	padding: 1em;
	
	color-scheme: light dark;
	color: light-dark(#333, #e4e4e4);
	background-color: light-dark(aliceblue, #333);
	
	font-weight: --light-dark(500, 300);
 	font-size: --light-dark(16px, 18px);
	border: 4px --light-dark(dashed, dotted) currentcolor;
	
	transition: all 0.25s ease, border-style 0.25s allow-discrete;
}

@layer layout {
	* {
		box-sizing: border-box;
	}

	:root {
		font-family: "Literata", serif;
		background: #fff;
	}

	body,
	html {
		height: 100%;
		margin: 0;
		padding: 0;
	}

	body {
		display: grid;
		place-content: safe center;
	}
}

@layer warning {
	.warning {
		padding: 1em;
		margin: 1em 0;
		border: 1px solid #ccc;
		background: rgba(255 255 205 / 0.8);
		color: black;
		text-align: center;
		position: fixed;
		bottom: 0;
		left: 1em;
		right: 1em;
	}

	.warning > :first-child {
		margin-top: 0;
	}

	.warning > :last-child {
		margin-bottom: 0;
	}

	.warning a {
		color: blue;
	}
	.warning--info {
		border: 1px solid #123456;
		background: rgb(205 230 255 / 0.8);
	}
	.warning--alarm {
		border: 1px solid red;
		background: #ff000010;
	}
}
              
            
!

JS

              
                
              
            
!
999px

Console