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.
Pure CSS
<div class="spinner anim-rotate">
<div class="spinner-inner"></div>
</div>
<br><br>
Original - 16px scaled to 92%
<div style="height:16px; width:16px;" class="mx-auto">
<svg fill="none" width="92%" height="92%" viewBox="0 0 16 16" class="anim-rotate" xmlns="http://www.w3.org/2000/svg" title="in_progress_icon" aria-hidden="true">
<path opacity=".5" d="M8 15A7 7 0 108 1a7 7 0 000 14v0z" stroke="#dbab0a" stroke-width="2"></path>
<path d="M15 8a7 7 0 01-7 7" stroke="#dbab0a" stroke-width="2"></path>
<path d="M8 12a4 4 0 100-8 4 4 0 000 8z" fill="#dbab0a"></path>
</svg>
</div>
<br><br>
16px not scaled
<div style="height:16px; width:16px;" class="mx-auto">
<svg fill="none" viewBox="0 0 16 16" class="anim-rotate" xmlns="http://www.w3.org/2000/svg" title="in_progress_icon" aria-hidden="true">
<path opacity=".5" d="M8 15A7 7 0 108 1a7 7 0 000 14v0z" stroke="#dbab0a" stroke-width="2"></path>
<path d="M15 8a7 7 0 01-7 7" stroke="#dbab0a" stroke-width="2"></path>
<path d="M8 12a4 4 0 100-8 4 4 0 000 8z" fill="#dbab0a"></path>
</svg>
</div>
<br><br>
Redrawn 14px
<div style="height:16px; width:16px;" class="mx-auto">
<svg fill="none" width="16" height="16" class="anim-rotate" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" title="in_progress_icon" aria-hidden="true">
<path opacity="0.5" d="M8 14C9.5913 14 11.1174 13.3679 12.2426 12.2426C13.3679 11.1174 14 9.5913 14 8C14 6.4087 13.3679 4.88258 12.2426 3.75736C11.1174 2.63214 9.5913 2 8 2C6.4087 2 4.88258 2.63214 3.75736 3.75736C2.63214 4.88258 2 6.4087 2 8C2 9.5913 2.63214 11.1174 3.75736 12.2426C4.88258 13.3679 6.4087 14 8 14Z" stroke="#dbab0a" stroke-width="2"/>
<path d="M8 11C8.79565 11 9.5587 10.6839 10.1213 10.1213C10.6839 9.55871 11 8.79565 11 8C11 7.20435 10.6839 6.44129 10.1213 5.87868C9.5587 5.31607 8.79565 5 8 5C7.20435 5 6.44129 5.31607 5.87868 5.87868C5.31607 6.44129 5 7.20435 5 8C5 8.79565 5.31607 9.55871 5.87868 10.1213C6.44129 10.6839 7.20435 11 8 11Z" fill="#dbab0a"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 15C9.8565 15 11.637 14.2625 12.9497 12.9497C14.2625 11.637 15 9.85652 15 8H13C13 9.32608 12.4732 10.5979 11.5355 11.5355C10.5979 12.4732 9.3261 13 8 13V15Z" fill="#dbab0a"/>
</svg>
</div>
<br><br>
Optimised 14px
<div style="height:16px; width:16px;" class="mx-auto">
<svg fill="none" width="16" height="16" class="anim-rotate" xmlns="http://www.w3.org/2000/svg">
<path opacity=".5" d="M8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12Z" stroke="#DBAB0A" stroke-width="2"/>
<path d="M8 11a3 3 0 1 0 0-6 3 3 0 0 0 0 6Z" fill="#DBAB0A"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 15a7 7 0 0 0 7-7h-2a5 5 0 0 1-5 5v2Z" fill="#DBAB0A"/>
</svg>
</div>
<br><br>
Just a <‌circle‌>
<div style="height:16px; width:16px;" class="mx-auto">
<svg class="anim-rotate" width="16px" height="16px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="50" fill="#DBAB0A"/>
</svg>
</div>
<br><br>
Just a <‌circle‌> but its parent rotates instead (doesn’t help)
<div class="anim-rotate" style="height:16px; width:16px;" class="mx-auto">
<svg width="16px" height="16px" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<circle cx="50" cy="50" r="50" fill="#DBAB0A"/>
</svg>
</div>
<br><br>
Redrawn 14px but two SVGs and the complete circles are static
<!-- Black canvas -->
<div style="height:16px; width:16px; position: relative;" class="mx-auto">
<!-- SVG for full circles -->
<svg fill="none" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" title="in_progress_icon" aria-hidden="true" style="position: absolute;">
<!-- Middle circle -->
<path d="M8 11C8.79565 11 9.5587 10.6839 10.1213 10.1213C10.6839 9.55871 11 8.79565 11 8C11 7.20435 10.6839 6.44129 10.1213 5.87868C9.5587 5.31607 8.79565 5 8 5C7.20435 5 6.44129 5.31607 5.87868 5.87868C5.31607 6.44129 5 7.20435 5 8C5 8.79565 5.31607 9.55871 5.87868 10.1213C6.44129 10.6839 7.20435 11 8 11Z" fill="#dbab0a"/>
<!-- Outer circle -->
<path opacity="0.5" d="M8 14C9.5913 14 11.1174 13.3679 12.2426 12.2426C13.3679 11.1174 14 9.5913 14 8C14 6.4087 13.3679 4.88258 12.2426 3.75736C11.1174 2.63214 9.5913 2 8 2C6.4087 2 4.88258 2.63214 3.75736 3.75736C2.63214 4.88258 2 6.4087 2 8C2 9.5913 2.63214 11.1174 3.75736 12.2426C4.88258 13.3679 6.4087 14 8 14Z" stroke="#dbab0a" stroke-width="2"/>
</svg>
<!-- SVG for semicircle -->
<svg fill="none" width="16" height="16" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" style="position: absolute;" class="anim-rotate">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 15C9.8565 15 11.637 14.2625 12.9497 12.9497C14.2625 11.637 15 9.85652 15 8H13C13 9.32608 12.4732 10.5979 11.5355 11.5355C10.5979 12.4732 9.3261 13 8 13V15Z" fill="#dbab0a"/>
</svg>
</div>
// Primer CSS animation utility class
.anim-rotate {
animation: rotate-keyframes 1s linear infinite;
}
@keyframes rotate-keyframes {
100% {
transform: rotate(360deg);
}
}
// Demo style
body {
margin: 5%;
}
// Demo style; hooks into existing centering class from prod
.mx-auto {
background-color: black;
}
// Styles for pure CSS icon
// Container
.spinner {
--spinner-container-size: 1em;
--spinner-icon-size: calc(var(--spinner-container-size) - 0.125em);
--spinner-icon-inset: calc((var(--spinner-container-size) - var(--spinner-icon-size)) / 2);
--spinner-center-size: 0.375em;
--spinner-center-inset: 0.125em;
--spinner-border-width: 0.125em;
--spinner-color: #DBAB0A;
--spinner-opacity: 0.5;
font-size: 16px;
height: var(--spinner-container-size);
width: var(--spinner-container-size);
position: relative;
}
// Border fragment
.spinner::after {
border-color: transparent;
border-radius: 50%;
border: var(--spinner-border-width) solid transparent;
// Give only 1/4 of the border a color to draw the fragment
border-top-color: var(--spinner-color);
box-sizing: border-box;
content: "";
height: var(--spinner-icon-size);
inset: var(--spinner-icon-inset);
position: absolute;
width: var(--spinner-icon-size);
}
// Full border
.spinner-inner {
border-radius: 50%;
border: var(--spinner-border-width) solid var(--spinner-color);
box-sizing: border-box;
height: var(--spinner-icon-size);
inset: var(--spinner-icon-inset);
opacity: var(--spinner-opacity);
position: absolute;
width: var(--spinner-icon-size);
}
// Solid inner circle
.spinner-inner::after {
background-color: var(--spinner-color);
border-radius: 50%;
content: "";
height: var(--spinner-center-size);
inset: var(--spinner-center-inset);
position: absolute;
width: var(--spinner-center-size);
}
Also see: Tab Triggers