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.
<body class="transition-colors duration-300">
<div class="min-h-screen p-8" id="main-container">
<!-- Header with Dark Mode Toggle -->
<div class="max-w-4xl mx-auto mb-8 flex justify-between items-center">
<a href="https://abhirajk.vercel.app" class="text-2xl font-bold hover:text-blue-500 transition">
Abhiraj K
</a>
<button onclick="toggleTheme()" class="p-2 rounded-lg bg-gray-200 dark:bg-gray-700 hover:bg-gray-300 dark:hover:bg-gray-600 transition">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" />
</svg>
</button>
</div>
<div class="max-w-4xl mx-auto">
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">
<!-- Circle Spinner -->
<div class="spinner-card bg-white dark:bg-gray-800 p-8 rounded-xl shadow-lg flex flex-col items-center space-y-4">
<h2 class="font-semibold text-lg dark:text-white">Circle Spinner</h2>
<div class="border-4 border-blue-500 dark:border-blue-400 rounded-full w-12 h-12 spinner-circle"></div>
<button class="px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition">
Loading...
</button>
</div>
<!-- Dots Spinner -->
<div class="spinner-card bg-white dark:bg-gray-800 p-8 rounded-xl shadow-lg flex flex-col items-center space-y-4">
<h2 class="font-semibold text-lg dark:text-white">Dots Spinner</h2>
<div class="dots-container">
<div class="dot bg-purple-500 dark:bg-purple-400"></div>
<div class="dot bg-purple-500 dark:bg-purple-400"></div>
<div class="dot bg-purple-500 dark:bg-purple-400"></div>
</div>
<button class="px-4 py-2 bg-purple-500 text-white rounded-lg hover:bg-purple-600 transition">
Processing...
</button>
</div>
<!-- Pulse Spinner -->
<div class="spinner-card bg-white dark:bg-gray-800 p-8 rounded-xl shadow-lg flex flex-col items-center space-y-4">
<h2 class="font-semibold text-lg dark:text-white">Pulse Spinner</h2>
<div class="w-12 h-12 rounded-full bg-green-500 dark:bg-green-400 pulse"></div>
<button class="px-4 py-2 bg-green-500 text-white rounded-lg hover:bg-green-600 transition">
Updating...
</button>
</div>
<!-- Wave Spinner -->
<div class="spinner-card bg-white dark:bg-gray-800 p-8 rounded-xl shadow-lg flex flex-col items-center space-y-4">
<h2 class="font-semibold text-lg dark:text-white">Wave Spinner</h2>
<div class="wave-container">
<div class="wave-bar bg-red-500 dark:bg-red-400"></div>
<div class="wave-bar bg-red-500 dark:bg-red-400"></div>
<div class="wave-bar bg-red-500 dark:bg-red-400"></div>
<div class="wave-bar bg-red-500 dark:bg-red-400"></div>
<div class="wave-bar bg-red-500 dark:bg-red-400"></div>
</div>
<button class="px-4 py-2 bg-red-500 text-white rounded-lg hover:bg-red-600 transition">
Syncing...
</button>
</div>
</div>
<!-- Footer with Backlinks -->
<footer class="mt-12 text-center">
<p class="text-gray-600 dark:text-gray-400">
Created by
<a href="https://abhirajk.vercel.app" class="text-blue-500 hover:text-blue-600 transition font-medium">
Abhiraj K
</a>
• View more projects on
<a href="https://abhirajk.vercel.app" class="text-blue-500 hover:text-blue-600 transition font-medium">
Portfolio
</a>
</p>
</footer>
</div>
</div>
<script>
</script>
</body>
</html>
/* Base styles and dark mode */
:root {
--primary: #3b82f6;
--background: #ffffff;
--text: #1f2937;
}
[data-theme="dark"] {
--primary: #60a5fa;
--background: #1f2937;
--text: #f3f4f6;
}
/* Circle Spinner */
.spinner-circle {
border-top-color: transparent;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
/* Dots Spinner */
.dots-container {
display: flex;
gap: 0.5rem;
align-items: center;
}
.dot {
width: 0.75rem;
height: 0.75rem;
border-radius: 50%;
animation: bounce 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) {
animation-delay: -0.32s;
}
.dot:nth-child(2) {
animation-delay: -0.16s;
}
@keyframes bounce {
0%,
80%,
100% {
transform: scale(0);
}
40% {
transform: scale(1);
}
}
/* Pulse Spinner */
.pulse {
animation: pulse 1.4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
@keyframes pulse {
0%,
100% {
opacity: 1;
transform: scale(1);
}
50% {
opacity: 0.5;
transform: scale(0.9);
}
}
/* Wave Spinner */
.wave-container {
display: flex;
gap: 0.25rem;
align-items: center;
height: 2rem;
}
.wave-bar {
width: 0.25rem;
height: 100%;
animation: wave 1.2s ease-in-out infinite;
}
.wave-bar:nth-child(2) {
animation-delay: 0.1s;
}
.wave-bar:nth-child(3) {
animation-delay: 0.2s;
}
.wave-bar:nth-child(4) {
animation-delay: 0.3s;
}
.wave-bar:nth-child(5) {
animation-delay: 0.4s;
}
@keyframes wave {
0%,
40%,
100% {
transform: scaleY(0.4);
}
20% {
transform: scaleY(1);
}
}
/* Floating animation for cards */
.spinner-card {
transition: all 0.3s ease;
}
.spinner-card:hover {
transform: translateY(-5px);
}
// Dark mode toggle functionality
function toggleTheme() {
const html = document.documentElement;
const currentTheme = html.getAttribute("data-theme");
const newTheme = currentTheme === "dark" ? "light" : "dark";
html.setAttribute("data-theme", newTheme);
// Toggle dark mode classes
document.body.classList.toggle("bg-gray-900");
document.body.classList.toggle("text-white");
}
// Check system preference for initial theme
if (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
) {
document.documentElement.setAttribute("data-theme", "dark");
document.body.classList.add("bg-gray-900", "text-white");
}
Also see: Tab Triggers