You want a little Christmas or New Year magic on your site — snow over the header, a row of glowing lights, fireworks behind "Happy New Year 2027". Below are four small pieces you can paste in today, each with a live demo: CSS snow, CSS Christmas lights, a gold "Happy New Year" heading and canvas fireworks in about 40 lines of JavaScript. The Christmas and New Year card makers on this site run on the same kind of code: configure a scene there and export it as a GIF, an MP4 or a ready-to-paste script — or build it yourself below.
The quick answer: a ready-made card
The fastest Happy New Year HTML code is two lines. Make a card in the New Year card maker or the Christmas card maker, open Get the code, download the .zip and paste:
<div id="new-year-card"></div>
<script src="new-year-card.js"></script>
You get fireworks, a sparkler, snow or gold lights with your own words in 3D gold or neon. The settings sit in a CONFIG at the top of the script (text, year, colours, speed, shape); fonts are in the zip. The card pauses when it scrolls off screen and shows a still frame to visitors who ask for reduced motion. Fill its box makes it fit a banner or a full-screen header of any size.
If you need a picture rather than code — for an email or a chat — the same cards download as GIFs:



Want to understand how such things work, or need something smaller? Read on.
Snow in pure CSS
No JavaScript and no images: each layer of snow is a background made of a few radial-gradient dots. Moving background-position down by exactly one tile makes the loop seamless. Three layers at different sizes and speeds give depth.
<div class="snow"></div>
.snow {
position: absolute; inset: 0;
background-image:
radial-gradient(3px 3px at 20px 30px, #fff 50%, transparent 51%),
radial-gradient(3px 3px at 90px 110px, #fff 50%, transparent 51%),
radial-gradient(2px 2px at 50px 160px, #fff 50%, transparent 51%),
radial-gradient(2px 2px at 140px 70px, #fff 50%, transparent 51%),
radial-gradient(1.5px 1.5px at 30px 90px, #cfe3ff 50%, transparent 51%),
radial-gradient(1.5px 1.5px at 120px 20px, #cfe3ff 50%, transparent 51%);
background-size: 180px 180px, 180px 180px, 130px 130px, 130px 130px, 90px 90px, 90px 90px;
animation: snow 9s linear infinite;
}
@keyframes snow {
to { background-position: 30px 180px, 30px 180px, 15px 130px, 15px 130px, 5px 90px, 5px 90px; }
}
The rule: each layer moves by exactly its own tile size (180px for a 180px tile), so the last frame equals the first. Add pointer-events: none when you lay it over real content, and turn it off for prefers-reduced-motion:
@media (prefers-reduced-motion: reduce) {
.snow { animation: none; }
}
Christmas lights in CSS
A bulb is a small rounded element with a box-shadow glow in its own colour. Every bulb runs the same "breathing" animation; a different animation-delay per colour makes them twinkle out of step, like a real string.
<ul class="lights"><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li><li></li></ul>
.lights {
display: flex; justify-content: space-between;
margin: 40px 0 0; padding: 0 16px;
list-style: none;
border-top: 2px solid #1c2a1f; /* the wire */
}
.lights li {
--c: #ff3b30;
width: 14px; height: 22px;
margin-top: 4px;
border-radius: 50% 50% 45% 45%;
background: var(--c);
box-shadow: 0 0 8px 2px var(--c), 0 0 24px 6px color-mix(in srgb, var(--c) 45%, transparent);
animation: glow 2.4s ease-in-out infinite;
}
.lights li:nth-child(5n + 2) { --c: #ffd60a; animation-delay: -0.5s; }
.lights li:nth-child(5n + 3) { --c: #30d158; animation-delay: -1.1s; }
.lights li:nth-child(5n + 4) { --c: #0a84ff; animation-delay: -1.6s; }
.lights li:nth-child(5n + 5) { --c: #ff9f0a; animation-delay: -2s; }
@keyframes glow {
50% { opacity: 0.35; box-shadow: 0 0 3px 1px var(--c); }
}
Negative delays start each bulb mid-cycle, so the string is already twinkling on the first frame instead of all bulbs starting together.
A gold "Happy New Year" heading
Gold is not one colour but a gradient with a bright band; background-clip: text paints it into the letters, and moving the gradient makes a light sweep across them. A soft drop-shadow adds the warm glow.
<h1 class="gold">Happy New Year 2027</h1>
.gold {
margin: 0;
font: 700 clamp(28px, 7vw, 56px)/1.1 Georgia, serif;
background: linear-gradient(100deg, #8a5a14 0%, #f7d77a 30%, #fff6d0 40%, #e0a93b 50%, #8a5a14 70%, #f7d77a 100%);
background-size: 300% 100%;
-webkit-background-clip: text; background-clip: text;
color: transparent;
filter: drop-shadow(0 0 12px rgb(255 190 80 / 0.35));
animation: sweep 5s ease-in-out infinite;
}
@keyframes sweep {
0%, 30% { background-position: 100% 0; }
70%, 100% { background-position: 0% 0; }
}
The keyframes hold still at both ends — the sweep happens, then the text rests. (More on pauses like this: how to add a pause between CSS animation loops.)
Fireworks in JavaScript (canvas)
CSS can fake a burst, but real fireworks — hundreds of sparks with gravity and fading trails — belong on a <canvas>. The whole idea fits in a few lines: a burst is a ring of particles with random speeds; every frame they slow down, fall a little and fade. The trail comes from not clearing the canvas fully: a translucent black rectangle each frame leaves the last positions glowing.
The HTML is one element, <canvas id="fw"></canvas>; the script:
const cv = document.getElementById("fw"), ctx = cv.getContext("2d");
const fit = () => { cv.width = innerWidth; cv.height = innerHeight; };
fit(); addEventListener("resize", fit);
const sparks = [];
function burst(x, y) {
const hue = Math.random() * 360, n = 70;
for (let i = 0; i < n; i++) {
const a = (i / n) * Math.PI * 2, v = 1.5 + Math.random() * 2.5;
sparks.push({ x, y, vx: Math.cos(a) * v, vy: Math.sin(a) * v,
life: 1, hue: hue + Math.random() * 30 });
}
}
let next = 0;
function frame(t) {
ctx.globalCompositeOperation = "source-over";
ctx.fillStyle = "rgba(8, 9, 10, 0.2)"; // trails
ctx.fillRect(0, 0, cv.width, cv.height);
ctx.globalCompositeOperation = "lighter"; // light adds up
if (t > next) {
burst(cv.width * (0.2 + Math.random() * 0.6), cv.height * (0.2 + Math.random() * 0.35));
next = t + 700 + Math.random() * 900;
}
for (let i = sparks.length - 1; i >= 0; i--) {
const s = sparks[i];
s.vx *= 0.98; s.vy = s.vy * 0.98 + 0.04; // drag + gravity
s.x += s.vx; s.y += s.vy; s.life -= 0.012;
if (s.life <= 0) { sparks.splice(i, 1); continue; }
ctx.fillStyle = `hsla(${s.hue}, 100%, 65%, ${s.life})`;
ctx.fillRect(s.x, s.y, 2, 2);
}
requestAnimationFrame(frame);
}
requestAnimationFrame(frame);
Three details make it look real:
globalCompositeOperation = "lighter"— overlapping sparks add their light, so the centre of a burst glows white.- Drag (
*= 0.98) — sparks fly out fast and slow down, instead of moving at a constant speed. - Trails from a translucent clear — no need to store a history of positions.
For a production version add rockets that rise before they burst, a few burst shapes (ring, willow, two-colour), pause when the tab is hidden and respect prefers-reduced-motion. That is what the card maker's fireworks do.
How to make an animation loop without a jump
A GIF or a video of a card has to end exactly where it began. The trick the card maker uses is simple: everything that repeats must repeat a whole number of times per loop.
// a wobble that wants to run at w radians per second,
// nudged so it makes a whole number of turns in `loop` seconds
const loopFreq = (w, loop) =>
(2 * Math.PI * Math.round((w * loop) / (2 * Math.PI))) / loop;
The same goes for falling snow (each flake falls a whole number of screen heights per loop) and for random events — fireworks are seeded by the frame number modulo the loop length, so frame t and frame t + loop are identical, pixel for pixel. That is why the cards can be exported as a GIF or a video that loops forever.
FAQ
Is there a pure HTML/CSS Happy New Year code without JavaScript?
Yes: the snow, the lights and the gold heading above are pure CSS. Fireworks need a canvas and a bit of JavaScript to look real.
Will snow or fireworks slow my site down?
The CSS demos above are cheap: they animate a background position or opacity. A canvas costs more — pause it when it is off screen (IntersectionObserver) or when the tab is hidden, as the ready-made cards do.
How do I make it respect reduced motion?
Wrap the animation in @media (prefers-reduced-motion: no-preference), or switch it off under reduce. In JavaScript, check matchMedia("(prefers-reduced-motion: reduce)").matches and draw one still frame.
Can I use the card code on a commercial site?
Yes. The code from Get the code is yours to use; the fonts in the zip are under the SIL Open Font License (OFL.txt is included).
Where can I get a GIF or a video instead of code?
The same card makers download a GIF, an MP4 or a PNG — see how to make an animated Merry Christmas GIF and Happy New Year GIFs.