Pen Settings



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


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


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.


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.


  <h1>CSS Color-Contrast() - Target Contrast Demo</h1>

  <p>Using the CSS color-contrast() function, we're able to dynamically adjust a text's color based upon its background with and without a target contrast defined. This feature is currently (18.3.2022) only available via the <a href="">Safari Technology Preview</a> browser.</p>

  <section class="wrapper">
      <h2>Without Target Contrast</h2>
      <p class="dark-mode">Dark on darker</p>
      <p class="light-mode">Light on lighter</p>
      <h2>With Target Contrast</h2>
      <p class="dark-mode with-target">Light on dark</p>
      <p class="light-mode with-target">Dark on light</p>



<div class="not-supported">The color-contrast() feature is not supported in your browser.</div>


                :root {
  --target-contrast: AA;

.light-mode {
  background: var(--bg);
  color: color-contrast(var(--bg) vs var(--color-list));

  &.with-target {
    color: color-contrast(
      var(--bg) vs var(--color-list) to var(--target-contrast)

.dark-mode {
  --bg: RGBA(0, 0, 0, 0.95);
  --color-list: RGB(17, 17, 17), RGB(13%, 13%, 13%);

.light-mode {
  --bg: HSL(0, 0%, 100%);
  --color-list: rgb(220, 220, 220), GhostWhite;

/* GLOBAL */
:root {
  --body-base: #d8e2dc;
  --color-primary: #4a7140;
  --scrollbar-bg: #222;

body::-webkit-scrollbar {
  width: 10px;
body {
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary) var(--scrollbar-bg);
body::-webkit-scrollbar-track {
  background: var(--scrollbar-bg);
body::-webkit-scrollbar-thumb {
  background-color: var(--color-primary);
  border-radius: 6px;
  border: 3px solid var(--scrollbar-bg);

body {
  font-family: "Barlow", sans-serif;
  font-size: 100%;
  letter-spacing: 0.25px;
  line-height: 1.75;
  margin: 0;
  padding: 0;

body {
  background-image: radial-gradient(
    circle farthest-corner at 0 0,
    #14371f 0%,
    #14371f 15.9%,
    var(--color-primary) 15.9%,
    var(--color-primary) 24.4%,
    var(--body-base) 24.5%,
    var(--body-base) 66%
  block-size: 100%;
  display: grid;
  min-block-size: 100vh;
  place-items: center;

a {
  color: #14371f;
  text-decoration: underline 1px dashed;
  text-underline-offset: min(5px, 1em);

  &:hover {
    color: #131313;

  &:focus {
    outline: 1px solid currentColor;
    outline-offset: 3px;

h2 {
  font-family: "Hubballi", cursive;
  line-height: 1.25;

main {
  inline-size: min(750px, 50vw);

.wrapper {
  display: grid;
  grid-gap: 2rem;
  grid-template-columns: 1fr 1fr;

  p {
    padding: 0.5rem 1rem;

.not-supported {
  background: #600;
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  position: fixed;
  inset-block-end: 1rem;
  inset-inline-start: 1rem;

  @supports (background: color-contrast(#000 vs #fff, #eee)) {
    display: none;