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>
  <h1>Text Contrast Issues That Cannot Be Detected with Automated Tools</h1>

  <p>
    These are based on real-world examples that we have encountered in audits, though this is simplified to show the salient bits.
  </p>

  <h2>Text on a Background Gradient</h2>

  <p>
    Pretend this is one "slide" from a carousel, which is where I see this crop up most frequently.
  </p>

  <div>
    <p>
      This is some sort of marketing text, usually justifying some sort of call to action following.
      <a href="#">Call to Action!</a>
    </p>
  </div>

  <h2>Text on a Background Texture</h2>

  <p>
    This is a CSS background texture. While the colors are at least embedded in the code, where they may fall below the text is impossible to determine
  </p>

  <div>
    <p>
      This is some sort of marketing text, usually justifying some sort of call to action following.
      <a href="#">Call to Action!</a>
    </p>
  </div>

  <h2>Text on a Background Image</h2>

  <p>
    In responsive layouts in particular it can be very hard to identify where an image will sit below the text.
  </p>

  <div>
    <p>
      This is some sort of marketing text, usually justifying some sort of call to action following.
      <a href="#">Call to Action!</a>
    </p>
  </div>

  <h2>Text on an Animated Background Image</h2>

  <p>
    This is a CSS animation, but an animated GIF can be just as hard to map to the text with an automated tool.
  </p>

  <div>
    <p>
      This is some sort of marketing text, usually justifying some sort of call to action following.
      <a href="#">Call to Action!</a>
    </p>
  </div>

  <h2>Text on an Animated Background Texture</h2>

  <p>
    Same as above, but with CSS only.
  </p>

  <div>
    <p>
      This is some sort of marketing text, usually justifying some sort of call to action following.
      <a href="#">Call to Action!</a>
    </p>
  </div>

  <h2>Text Absolutely Positioned over a Box</h2>

  <p>
    In this case the text is not in a container. Oh. Nope. This one was flagged. Good job, tool.
  </p>

  <div>
  </div>
  <p>
    This is some sort of marketing text, usually justifying some sort of call to action following.
    <a href="#">Call to Action!</a>
  </p>
  


  <h2>Text with A Contrasty "Outline"</h2>

  <p>
    In this example, the link would trigger a false positive. The text is the same color as the background, but with a border-like style to make it stand out more.
  </p>

  <div>
    <p>
      This is some sort of marketing text, usually justifying some sort of call to action following.
      <a href="#">Call to Action!</a>
    </p>
  </div>
</main>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:400,700);
body {
  background-color: #fff;
  font-size: 100%;
  color: #333;
  font-family: Lato, Arial, sans-serif;
  padding: 0;
  margin: 0;
}

main {
  display: block;
  box-sizing: border-box;
  margin: 1em .5em;
  padding: 0 0;
  color: #000;
  line-height: 1.5;
}

input {
  font-size: 100%;
  color: #333;
  font-family: Lato, Arial, sans-serif;
  border: .08em solid #333;
  padding: .25em .25em;
}

button {
  font-size: 2em;
  border: .1em solid #000;
  background-color: #fff;
  color: #000;
  border-radius: 50%;
  width: 1.5em;
  height: 1.5em;
  margin-left: 1em;
}

button:hover,
button:focus {
  background-color: #000;
  color: #fff;
}

main > h2 {
  clear: both;
}

main > div {
  display: block;
  box-sizing: border-box;
  margin: 1em auto;
  padding: 2.5em;
  color: #000;
  background-color: rgba(204, 204, 204, .2);
  border: .07em solid rgba(0, 0, 0, .8);
  border-radius: .25em;
  clear: both;
}

main div:nth-of-type(1) {
  background-image: linear-gradient(to top, #30cfd0 0%, #330867 70%);
}

main div:nth-of-type(2) {
  background: linear-gradient(45deg, #dca 12%, transparent 0, transparent 88%, #dca 0), linear-gradient(135deg, transparent 37%, #a85 0, #a85 63%, transparent 0), linear-gradient(45deg, transparent 37%, #dca 0, #dca 63%, transparent 0) #753;
  background-size: 25px 25px;
}

main div:nth-of-type(3) {
  background-image: url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/shape-outside-2.jpg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 0 80%;
}

main div:nth-of-type(4) {
  background-color: rgb(247, 231, 206);
  background: linear-gradient(to right, rgba(229, 196, 146, .5) 0, rgba(247, 231, 206, .25) 25%, rgba(247, 231, 206, .25) 75%, rgba(229, 196, 146, .5)), url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/drops1.png) 100% 0 repeat, url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/drops2.png) 50% 50% repeat, url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/drops3.png) 0 0 repeat, linear-gradient(to right, rgb(229, 196, 146) 0, rgb(247, 231, 206) 25%, rgb(247, 231, 206) 75%, rgb(229, 196, 146));
  background-size: cover, 350px, 250px, 150px, cover;
  background-attachment: fixed, fixed, fixed, fixed;
  -webkit-animation: EFFERVESCE 3s linear infinite;
  animation: EFFERVESCE 8s linear infinite;
}

main div:nth-of-type(5) {
  background: linear-gradient(135deg, #ECEDDC 25%, transparent 25%), linear-gradient(225deg, #ECEDDC 25%, transparent 25%), linear-gradient(315deg, #ECEDDC 25%, transparent 25%), linear-gradient(45deg, #ECEDDC 25%, transparent 25%);
  background-size: 100px 100px;
  background-color: #c00;
  animation: ZIGGYZAGGY 16s linear infinite;
}

main div:nth-of-type(6) {
  background-color: #333;
  height: 15em;
}

main div:nth-of-type(6) + p {
  box-sizing: border-box;
  padding: 2.5em;
  position: absolute;
  margin-top: -15.5em;
  margin-right: 1em;
}

main > div a,
main div:nth-of-type(6) + p a {
  display: block;
  box-sizing: border-box;
  width: 10em;
  margin: 1em auto 0 auto;
  padding: .5em 0;
  text-align: center;
  border: .07em solid rgba(255, 255, 255, .8);
  background-color: #33c;
  border-radius: .5em;
  text-decoration: none;
  color: #fff;
  font-weight: bold;
  font-size: .8em;
}

main div:nth-of-type(7) a {
  font-size: 200%;
  font-weight: bold;
  color: #33c;
  text-shadow: 0.02em 0.02em 0 #ff0, -0.02em -0.02em 0 #ff0, -0.02em 0.02em 0 #ff0, 0.02em -0.02em 0 #ff0, 0 0.02em 0 #ff0, 0 -0.02em 0 #ff0, -0.02em 0 0 #ff0, 0.02em 0 0 #ff0;
}

main > div a:hover,
main > div a:focus,
main div:nth-of-type(6) + p a:hover,
main div:nth-of-type(6) + p a:focus {
  background-color: #090;
  box-shadow: 0 0 1em #000;
}

@media all and (min-width: 36em) {
  main {
    margin: 1em 2em;
  }
  main > div,
  main div:nth-of-type(6) + p {
    padding: 2.5em 11em 2.5em 4em;
    font-size: calc(10px + 2vw);
  }
  form > div::after {
    content: "";
    display: block;
    clear: both;
  }
}

@-webkit-keyframes EFFERVESCE {
  from {
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0;
  }
  to {
    background-position: 0 0, 0 -700px, 0 -500px, 0 -300px, 0 0;
  }
}

@keyframes EFFERVESCE {
  from {
    background-position: 0 0, 0 0, 0 0, 0 0, 0 0;
  }
  to {
    background-position: 0 0, 0 -700px, 0 -500px, 0 -300px, 0 0;
  }
}

@keyframes ZIGGYZAGGY {
  from {
    background-position: 25% 0, 25% 0, 0 0, 0 0;
  }
  to {
    background-position: 125% 0, 125% 0, 100% 0, 100% 0;
  }
}
              
            
!

JS

              
                /* Getting around CodePen's inability to allow me to set a lang on the <html> element */

var h = document.querySelector("html"); 
h.setAttribute("lang", "en");
              
            
!
999px

Console