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.
<svg height="0" style="display: none;">
<symbol id="hipchat_star" preserveAspectRatio="xMidYMid" width="29" height="28" viewBox="0 0 29 28">
<path d="M28.842,11.728 L22.247,17.406 C22.023,17.599 21.924,17.901 21.990,18.189 L23.888,26.467 C24.085,27.328 23.148,28.002 22.392,27.544 L14.947,23.029 C14.692,22.875 14.371,22.875 14.116,23.029 L6.670,27.544 C6.286,27.777 5.856,27.715 5.551,27.488 C5.221,27.275 5.011,26.881 5.114,26.430 L7.012,18.152 C7.078,17.863 6.979,17.562 6.755,17.369 L0.160,11.690 C-0.497,11.125 -0.171,10.051 0.689,9.943 L9.490,8.842 C9.766,8.808 10.005,8.632 10.120,8.379 L13.559,0.781 C13.830,0.182 14.542,0.049 15.022,0.368 C15.197,0.466 15.349,0.610 15.444,0.819 L18.883,8.416 C18.936,8.535 19.022,8.632 19.121,8.711 C19.221,8.775 19.331,8.827 19.452,8.842 L28.252,9.943 C28.385,9.959 28.499,10.005 28.605,10.062 C29.238,10.345 29.418,11.232 28.842,11.728 Z"
class="base" />
<path d="M18.757,10.753 L24.874,11.516 C25.217,11.559 25.348,11.987 25.087,12.214 L20.508,16.185 C19.903,16.705 19.684,17.350 19.852,18.120 L21.138,23.655 C21.218,24.000 20.842,24.271 20.539,24.087 L15.503,21.023 C15.190,20.836 14.846,20.742 14.471,20.742 C14.095,20.742 13.752,20.836 13.439,21.023 L8.403,24.087 C8.100,24.271 7.724,24.000 7.804,23.655 L9.091,18.120 C9.257,17.350 9.038,16.705 8.434,16.185 L3.855,12.214 C3.594,11.987 3.725,11.559 4.068,11.516 L10.186,10.753 C10.915,10.670 11.436,10.285 11.749,9.598 L14.106,4.408 C14.248,4.095 14.694,4.095 14.836,4.408 L17.193,9.598 C17.505,10.285 18.026,10.670 18.757,10.753 L18.757,10.753 Z"
class="mask" fill="currentColor" />
</symbol>
</svg>
<div class="container">
<a href="#" class="star">
<div class="star-outer">
<svg class="star-icon">
<use xlink:href="#hipchat_star" class="star-icon" />
</svg>
</div>
</a>
</div>
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.star {
margin: 0px auto;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: column;
flex-flow: column;
-webkit-justify-content: center;
justify-content: center;
text-align: center;
}
.star use {
-moz-transition: all .2s ease-in;
-o-transition: all .2s ease-in;
-webkit-transition: all .2s ease-in;
transition: all .2s ease-in;
fill: #707070;
color: #fff;
}
.starred use {
fill: #f6c342;
color: #f6c342;
}
.star,
.star-icon,
.star-outer {
display: block;
width: 29px;
height: 28px;
}
.starred {
animation: hop .6s forwards;
transform-origin: 50% 50%;
-webkit-transform-origin: 50% 50%;
transition-timing-function: ease-in-out;
}
.starred .star-outer {
animation: spin .6s forwards;
transform-origin: 50% 50%;
-webkit-transform-origin: 50% 50%;
transition-timing-function: ease-in-out;
}
.unstarred .star-outer {
animation: unspin .3s forwards;
transform-origin: 50% 50%;
-webkit-transform-origin: 50% 50%;
transition-timing-function: ease-in-out;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
33% {
transform: rotate(175deg);
}
66% {
transform: rotate(120deg);
}
100% {
transform: rotate(144deg);
}
}
@keyframes unspin {
0% {
transform: rotate(142deg);
}
100% {
transform: rotate(72deg);
}
}
@keyframes hop {
0% {
transform: translate(0, 0px);
}
17% {
transform: translate(2px, -10px);
}
33% {
transform: translate(4px, 0px);
}
50% {
transform: translate(-2px, -7px);
}
66% {
transform: translate(-4px, -0px);
}
84% {
transform: translate(-2, -5px);
}
100% {
transform: translate(0, 0px);
}
}
$("a.star").click(function() {
if ($(this).hasClass("starred")) {
$(this).removeClass("starred");
$(this).addClass("unstarred");
} else if ($(this).hasClass("unstarred")) {
$(this).removeClass("unstarred");
$(this).addClass("starred");
} else {
$(this).addClass("starred");
}
});
Also see: Tab Triggers