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.
<div>
<div class="star"></div>
<input type="radio" name="star" value="0">
<input type="radio" name="star" value="1">
<input type="radio" name="star" value="2">
<input type="radio" name="star" value="3">
<input type="radio" name="star" value="4">
<input type="radio" name="star" value="5" checked>
</div>
@property --d {
syntax: '<number>';
initial-value: 1;
inherits: true;
}
input{
--d:0;
appearance: none;
&:checked,
&:has(~:checked ) {
--d: 5;
}
&:checked {
animation: bounce 1s;
}
&[value="0"]{
--d: 0;
}
}
.star, input {
width: 24px;
height: 24px;
background-image:
conic-gradient(from -36deg, #66797C calc(var(--d) * 72deg), transparent calc(var(--d) * 72deg)),
url("data:image/svg+xml,%3csvg viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3e %3cpath d='M5.27745 23C5.02728 23.0018 4.78358 22.9196 4.58452 22.7663C4.39137 22.6179 4.24648 22.4144 4.1685 22.1821C4.09051 21.9497 4.083 21.6991 4.14691 21.4624L6.25002 14.4264L0.46354 9.98582C0.272381 9.83348 0.130775 9.62661 0.0570884 9.39196C-0.0165986 9.15731 -0.0190085 8.90568 0.050188 8.66964C0.130947 8.43542 0.279845 8.23138 0.477266 8.0843C0.674688 7.93722 0.91145 7.85397 1.15647 7.84549L8.45034 7.68558L10.8816 0.747979C10.975 0.526087 11.1309 0.336882 11.3297 0.203892C11.5286 0.0709018 11.7616 0 12 0C12.2384 0 12.4714 0.0709018 12.6703 0.203892C12.8691 0.336882 13.025 0.526087 13.1184 0.747979L15.5497 7.68558L22.8435 7.84549C23.0885 7.85397 23.3253 7.93722 23.5227 8.0843C23.7202 8.23138 23.8691 8.43542 23.9498 8.66964C24.019 8.90568 24.0166 9.15731 23.9429 9.39196C23.8692 9.62661 23.7276 9.83348 23.5365 9.98582L17.75 14.4264L19.8531 21.4624C19.917 21.6991 19.9094 21.9497 19.8314 22.1821C19.7534 22.4144 19.6086 22.6179 19.4154 22.7663C19.2144 22.9037 18.9773 22.9772 18.7346 22.9772C18.492 22.9772 18.2549 22.9037 18.0539 22.7663L11.9149 18.584L5.94611 22.7908C5.74832 22.9254 5.51575 22.9981 5.27745 23ZM11.9149 1.1539L9.48361 8.53433C9.44239 8.65262 9.36707 8.75569 9.2674 8.83024C9.16772 8.90479 9.04823 8.94739 8.92438 8.95255L1.2415 9.11247L7.38056 13.7375C7.48048 13.8146 7.55488 13.9205 7.59395 14.0414C7.63303 14.1622 7.63493 14.2921 7.59937 14.4141L5.37472 21.7945L11.6232 17.3047C11.7268 17.2323 11.8497 17.1934 11.9757 17.1934C12.1016 17.1934 12.2246 17.2323 12.3282 17.3047L18.6374 21.7576L16.352 14.3772C16.3165 14.2552 16.3183 14.1253 16.3574 14.0045C16.3964 13.8836 16.4709 13.7777 16.5708 13.7006L22.6491 9.00175L14.9783 8.91565C14.8545 8.91049 14.735 8.86789 14.6353 8.79334C14.5357 8.71879 14.4603 8.61572 14.4191 8.49743L11.9149 1.1539Z' fill='%2366797C'/%3e %3c/svg%3e");
transition: --d 1s ease-out;
clip-path: path("M4.3935 22.7663C4.58426 22.9196 4.81781 23.0018 5.05755 23C5.28593 22.9981 5.5088 22.9254 5.69836 22.7908L11.4184 18.584L17.3016 22.7663C17.4943 22.9037 17.7215 22.9772 17.954 22.9772C18.1866 22.9772 18.4138 22.9037 18.6064 22.7663C18.7915 22.6179 18.9304 22.4144 19.0051 22.1821C19.0799 21.9497 19.0871 21.6991 19.0259 21.4624L17.0104 14.4264L22.5558 9.98582C22.739 9.83348 22.8747 9.62661 22.9453 9.39196C23.0159 9.15731 23.0182 8.90568 22.9519 8.66964C22.8745 8.43542 22.7318 8.23138 22.5426 8.0843C22.3534 7.93722 22.1265 7.85397 21.8917 7.84549L14.9018 7.68558L12.5718 0.747979C12.4823 0.526087 12.3329 0.336882 12.1424 0.203892C11.9518 0.0709018 11.7284 0 11.5 0C11.2716 0 11.0482 0.0709018 10.8576 0.203892C10.6671 0.336882 10.5178 0.526087 10.4282 0.747979L8.09824 7.68558L1.10828 7.84549C0.873473 7.85397 0.646576 7.93722 0.45738 8.0843C0.268185 8.23138 0.125491 8.43542 0.0480969 8.66964C-0.0182165 8.90568 -0.015907 9.15731 0.0547097 9.39196C0.125326 9.62661 0.261032 9.83348 0.444226 9.98582L5.98961 14.4264L3.97412 21.4624C3.91288 21.6991 3.92007 21.9497 3.99481 22.1821C4.06955 22.4144 4.20839 22.6179 4.3935 22.7663ZM11.3202 11.5357L11.4931 11.7358V11.734L11.4956 11.7353L11.4978 11.7328L11.3202 11.5357Z");
}
div:has([value="0"]:checked) {
--d: 0;
}
div:has([value="1"]:checked) {
--d: 1;
}
div:has([value="2"]:checked) {
--d: 2;
}
div:has([value="3"]:checked) {
--d: 3;
}
div:has([value="4"]:checked) {
--d: 4;
}
div:has([value="5"]:checked) {
--d: 5;
}
@keyframes bounce {
0% { transform:scale(1); }
60% { transform:scale(1.3); }
70% { transform:scale(1); }
95% { transform:scale(1.15); }
97% { transform:scale(1); }
99% { transform:scale(1.07); }
100% { transform:scale(1); }
}
Also see: Tab Triggers