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.
<button>I'm a button</button>
<p>(hover me, then click me)</p>
body {
align-items: center;
background-color: #779fb8;
display: flex;
flex-direction: column;
font-family: 'NB-Int-Regular', -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
height: 100vh;
justify-content: center;
}
button {
background-color: #000;
border: 0;
color: #fff;
cursor: pointer;
font-size: 2rem;
margin-bottom: 3rem;
padding: .75rem 1.5rem;
position: relative;
text-transform: uppercase;
transition: color .2s ease-out;
z-index: 1;
}
button::before {
background-color: #fff;
background: linear-gradient(
to bottom,
#000 0%,
#000 2.5%,
#fff 2.5%,
#fff 9%,
#000 9%,
#000 14%,
#fff 14%,
#fff 19.5%,
#000 19.5%,
#000 24.5%,
#fff 24.5%,
#fff 30%,
#000 30%,
#000 35%,
#fff 35%,
#fff 39%,
#000 39%,
#000 43%,
#fff 43%,
#fff 49%,
#000 49%,
#000 55%,
#fff 55%,
#fff 61%,
#000 61%,
#000 68%,
#fff 68%,
#fff 74%,
#000 74%,
#000 80%,
#fff 80%,
#fff 87%,
#000 87%,
#000 91%,
#fff 91%,
#fff 96%,
#000 96%,
#000 98%,
#fff 98%,
#fff 100%
);
border: 5px solid #000;
content: '';
height: 90%;
left: -30px;
position: absolute;
top: 14px;
transform: skewY(-45deg);
width: 20px;
z-index: -1;
}
button::after {
background-color: #fff;
background: linear-gradient(
to right,
#000 0%,
#000 .5%,
#fff .5%,
#fff 1%,
#000 1%,
#000 1.5%,
#fff 1.5%,
#fff 2.5%,
#000 2.5%,
#000 3.5%,
#fff 3.5%,
#fff 4%,
#000 4%,
#000 4.5%,
#fff 4.5%,
#fff 5.5%,
#000 5.5%,
#000 6.5%,
#fff 6.5%,
#fff 7%,
#000 7%,
#000 7.5%,
#fff 7.5%,
#fff 8.5%,
#000 8.5%,
#000 9%,
#fff 9%,
#fff 10%,
#000 10%,
#000 11%,
#fff 11%,
#fff 11.5%,
#000 11.5%,
#000 12%,
#fff 12%,
#fff 14%,
#000 14%,
#000 15%,
#fff 15%,
#fff 16.5%,
#000 16.5%,
#000 17.5%,
#fff 17.5%,
#fff 18%,
#000 18%,
#000 19%,
#fff 19%,
#fff 21%,
#000 21%,
#000 22%,
#fff 22%,
#fff 23%,
#000 23%,
#000 23.5%,
#fff 23.5%,
#fff 24.5%,
#000 24.5%,
#000 25%,
#fff 25%,
#fff 27%,
#000 27%,
#000 27.5%,
#fff 27.5%,
#fff 28.5%,
#000 28.5%,
#000 29.5%,
#fff 29.5%,
#fff 31%,
#000 31%,
#000 31.5%,
#fff 31.5%,
#fff 32%,
#000 32%,
#000 33%,
#fff 33%,
#fff 35%,
#000 35%,
#000 35.5%,
#fff 35.5%,
#fff 37%,
#000 37%,
#000 38%,
#fff 38%,
#fff 40%,
#000 40%,
#000 41.5%,
#fff 41.5%,
#fff 42.5%,
#000 42.5%,
#000 43%,
#fff 43%,
#fff 44%,
#000 44%,
#000 46%,
#fff 46%,
#fff 47%,
#000 47%,
#000 48%,
#fff 48%,
#fff 50%,
#000 50%,
#000 50.5%,
#fff 50.5%,
#fff 52%,
#000 52%,
#000 53.5%,
#fff 53.5%,
#fff 54.5%,
#000 54.5%,
#000 56%,
#fff 56%,
#fff 58%,
#000 58%,
#000 60%,
#fff 60%,
#fff 63%,
#000 63%,
#000 64%,
#fff 64%,
#fff 67%,
#000 67%,
#000 67.5%,
#fff 67.5%,
#fff 68%,
#000 68%,
#000 69%,
#fff 69%,
#fff 71%,
#000 71%,
#000 73%,
#fff 73%,
#fff 74.5%,
#000 74.5%,
#000 76%,
#fff 76%,
#fff 77%,
#000 77%,
#000 79%,
#fff 79%,
#fff 81%,
#000 81%,
#000 81.5%,
#fff 81.5%,
#fff 83%,
#000 83%,
#000 83.5%,
#fff 83.5%,
#fff 85%,
#000 85%,
#000 86%,
#fff 86%,
#fff 88%,
#000 88%,
#000 89.5%,
#fff 89.5%,
#fff 91%,
#000 91%,
#000 92%,
#fff 92%,
#fff 94%,
#000 94%,
#000 95.5%,
#fff 95.5%,
#fff 97%,
#000 97%,
#000 97.5%,
#fff 97.5%,
#fff 99%,
#000 99%,
#000 100%
);
border: 5px solid #000;
bottom: -32px;
content: '';
height: 23px;
position: absolute;
right: 16px;
transform: skewX(-45deg);
width: 95%;
z-index: -1;
}
button:hover,
button:active {
color: #f86638;
}
button:hover::before {
animation: vertical 5s linear infinite;
}
button:hover::after {
animation: horizontal 5s linear infinite;
}
button:active {
left: -30px;
top: 30px;
}
button:active::before {
visibility: hidden;
}
button:active::after {
visibility: hidden;
}
@keyframes vertical {
from {
background-position: 0 0;
}
to {
background-position: 0 -100px;
}
}
@keyframes horizontal {
from {
background-position: 0 0;
}
to {
background-position: -100px 0;
}
}
Also see: Tab Triggers