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>
    <header class="inverted">
    <h2>Highlight on hover elements anywhere on the page </h2> 
     <p>You should hover over a question to highlight a code listing. You should hover over a code listing to hightlight a question.</p>
  </header> 
  <h2>CSS Quiz</h2>
  <section id="questions">
  <p style="--is: --example1">
    <em style="--for: --code1">Question 1: Which code block tethers a target element to a HTML element using an anchor attribute?</em>
  </p>
  <p style="--is: --example2"><em style="--for: --code2">
    Question 2: Which code block gives control to the Brwoser for positioning the anchor target?</em>
  </p>
  </section>
  <section id="code-listings">
<pre style="--is: --code1; --for: --example1;">
<code>
.anchor-target {
  position: absolute;
  left: anchor(implicit right);
  bottom: anchor(implicit top);
}
</code>
</pre>
<pre style="--is: --code2; --for: --example2;">
<code>
.anchor-target {
  position: absolute;
  left: anchor(auto);
  bottom: anchor(auto);
}
</code>
</pre>
  </section>
</main>
              
            
!

CSS

              
                #questions {
  --box-margin: 8px;
  --box-border: 5px solid green;
}

#code-listings {
  --box-margin: 2px;
  --box-border: 1px solid red;
}        

[style*="--is:"] {
  anchor-name: var(--is);
  cursor: help;
}

[style*="--for:"]:is(:hover, :focus-visible)::after {
  content: "";
  position: absolute;

  top: calc(anchor(var(--for) top) - var(--box-margin));
  right: calc(anchor(var(--for) right) - var(--box-margin));
  bottom: calc(anchor(var(--for) bottom) - var(--box-margin));
  left: calc(anchor(var(--for) left) - var(--box-margin));
  
  border: var(--box-border);
}

pre > code {
	display: block;
	background: #f1f1f1;
	padding: 1.33em;
	border-radius: 0.33em;
}
              
            
!

JS

              
                
              
            
!
999px

Console