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

              
                <h1>The <a href="https://brm.us/css-has" target="_top">CSS <code>:has()</code> selector</a> is way more than a “Parent Selector”</h1>

<div class="warning">
	<p>⚠️ Your browser does not support the CSS <code>:has()</code> selector so this demo won't work. Please try Safari TP 137.</p>
</div>

<pre><code>figure:has(figcaption) img {
    outline: 10px dashed red;
}</code></pre>

<h2>With figcaption</h2>
<figure>
	<img src="https://brm.us/avatar" alt="Avatar of Bramus" title="Avatar of Bramus" height="600" width="600" />
	<figcaption>Avatar of Bramus</figcaption>
</figure>

<h2>Without figcaption</h2>
<figure>
	<img src="https://brm.us/avatar" alt="Avatar of Bramus" title="Avatar of Bramus" height="600" width="600" />
</figure>

<footer>
	<p>(demo for <a href="https://brm.us/css-has" target="_top">https://brm.us/css-has</a>)</p>
</footer>
              
            
!

CSS

              
                figure:has(figcaption) img {
	outline: 10px dashed red;
}

img {
	max-width: 100%;
	height: auto;
}

html {
  max-width: 70ch;
  padding: 3em 1em;
  margin: auto;
  line-height: 1.75;
  font-size: 1.25em;
}

h1 {
	line-height: 1.15;
}

pre {
	border-left: 0.2rem solid rgba(0 0 0 / 0.25);
	background: #f4f4f4;
	padding: 0.5rem;
}

figcaption {
	text-align: center;
}

a {
	color: blue;
	text-decoration: none;
	border-bottom: 0.1em solid currentcolor;
	display: inline-block;
}

footer {
	text-align: center;
	font-style: italic;
}


/* Show/Hide Warning if no container Queries Support */
@supports (selector(:has(*))) {
	.info, .warning {
		display: none;
	}
}
.info, .warning {
	padding: 1em;
	border: 1px solid #123456;
	background: rgba(205 230 255 / 0.8);
	color: #123456;
}
.warning {
	background: #ffe3003d;
	border-color: #ffc700;
	color: #333;
}

.info p, .warning p {
	margin: 0;
	padding: 0;
}
              
            
!

JS

              
                
              
            
!
999px

Console