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 class="content">
  Lorem, ipsum dolor sit amet consectetur adipisicing
  <span class="inline" id="ref-1">1</span>
  elit. Voluptatum
  <span class="inline" id="ref-2">2</span>
  nihil
  <span class="inline" id="ref-3">3</span>
  facilis quam tempore quo amet, facere neque sequi inventore deleniti, soluta illum fugit molestias ea obcaecati iure non in magni.
</div>

<div class="absolute" anchor="ref-1">
  outside1<br/>newline<br />newline
</div>
<div class="absolute" anchor="ref-2">
  outside2
</div>
<div class="absolute" anchor="ref-3">
  outside3<br />newline
</div>

<p id="warning">You are viewing this demonstration with a browser that doesn’t support anchor positioning, so any conclusions you try to draw from the results are likely to be misleading at best.</p>

<p>N.B. This pen was <a href="https://codepen.io/kizu/pen/abRRavB">forked from Roman Komarov’s genius</a>.</p>

              
            
!

CSS

              
                .content {
  width: 15em;
  anchor-name: --content;
}

.inline {
  background: pink;
  padding-inline: 0.5em;
}

.absolute {
  position: absolute;
  anchor-name: --absolute;
  left: anchor(--content right);
  top: max(
    anchor(top),
    anchor(--absolute bottom)
  );
  border: 1px solid pink;
}

/* -----------------------------
Everything after this comment is not relevant to the example, it’s just prettifying stuff.
----------------------------- */
body > p:last-of-type {
  padding-block: 1em 0;
  margin-block: 2.5em 0;
  border-block-start: 1px solid;
  font-style: italic;
}

#warning {
	position: fixed;
	top: 0;
  right: 0;
  width: 50%;
	padding: 2em;
	background: #FAA;
	font-weight: bold;
}
@supports (anchor-name: --name) {
	#warning {display: none;}
}
              
            
!

JS

              
                
              
            
!
999px

Console