Pen Settings

HTML

CSS

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

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

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.

HTML

              
                <p>Historically, iframes don't have opaque backgrounds unless the embedded document requests one. This can be a pain for the external document if they don't control the embed! Especially when you add dark/light mode support.
</p>
<p>
	For each test, I'm using the <code>color-scheme</code> CSS property to make the <code>figure</code> element either light mode, dark mode, or match your browser settings, with an appropriate background color. The embeddeded documents don't have any styling or background colors of their own; however, some of them use the <code>&lt;meta name='color-scheme'&gt;</code> element to turn on color-scheme support.
</p>
<p>If everything works according to spec, there should be no white text on light pink or white backgrounds, and no black text on purple or black backgrounds &mdash; the browser should insert an opaque black or white canvas on the iframe to avoid this. Currently (May 2022) not implemented in Firefox; I also thought I discovered some bugs in Chromium while playing around with dark/light emulation, but now I can't reproduce, so 🤷🏻‍♀️.</p>


<h2> Iframe src with no dark mode support </h2>
<figure class="light">
	<iframe src="data:text/html,<DOCTYPE html><h1>This is a test</h1>"></iframe>
</figure>

<figure class="dark">
	<iframe src="data:text/html,<DOCTYPE html><h1>This is a test</h1>"></iframe>
</figure>

<figure class="flex">
	<iframe src="data:text/html,<DOCTYPE html><h1>This is a test</h1>"></iframe>
</figure>

<h2> Iframe src with color-scheme support, user preference </h2>
<figure class="light">
	<iframe src="data:text/html,<DOCTYPE html><meta name='color-scheme' content='dark light'><h1>This is a test</h1>"></iframe>
</figure>

<figure class="dark">
	<iframe src="data:text/html,<DOCTYPE html><meta name='color-scheme' content='dark light'><h1>This is a test</h1>"></iframe>
</figure>

<figure class="flex">
	<iframe src="data:text/html,<DOCTYPE html><meta name='color-scheme' content='dark light'><h1>This is a test</h1>"></iframe>
</figure>

<h2> Iframe src with dark mode requested </h2>
<figure class="light">
	<iframe src="data:text/html,<DOCTYPE html><meta name='color-scheme' content='dark'><h1>This is a test</h1>"></iframe>
</figure>

<figure class="dark">
	<iframe src="data:text/html,<DOCTYPE html><meta name='color-scheme' content='dark'><h1>This is a test</h1>"></iframe>
</figure>

<figure class="flex">
	<iframe src="data:text/html,<DOCTYPE html><meta name='color-scheme' content='dark'><h1>This is a test</h1>"></iframe>
</figure>

<h2> Iframe src with raw text document </h2>
<figure class="light">
	<iframe src="data:text,This is a test"></iframe>
</figure>

<figure class="dark">
	<iframe src="data:text,This is a test"></iframe>
</figure>

<figure class="flex">
	<iframe src="data:text,This is a test"></iframe>
</figure>
              
            
!

CSS

              
                iframe {
	width: 100%;
	height: 8em;
}
p {
	max-width: 50em;
}

figure {
	display: block;
	padding: 0.5em;
	margin: 1em 0;
	border: thin dashed gray;
}

figure.light {
	background: pink;
	color-scheme: light;
}
figure.dark {
	background: indigo;
	color-scheme: dark;
}
figure.flex {
	background: canvas;
	color-scheme: light dark;
}
              
            
!

JS

              
                
              
            
!
999px

Console