HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
@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;
}
}
/* 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");
Also see: Tab Triggers