Skip to main content
Creative Coding Projects

Build an Interactive Birthday Surprise Page with Confetti & Music

Build an interactive birthday surprise page featuring confetti explosions, background music, and a reveal animation. Complete HTML/CSS/JS source code included.

G

gs_admin

Author & Reviewer

Published

Jul 16, 2026

Read Time

15 min read

love.html
💝
Creative Coding Projects

🎯 What You'll Build

A multi-step birthday surprise experience: Landing page → "Click to Open" → Message reveal → Confetti celebration + Music!

---

🔗 Live Demo

👉 Try the Live Demo →

---

📦 Premium Version

> ☕ Download Premium (8 themes + photo gallery) →

---

🛠️ The Multi-Page Flow

HTML Structure

html
1234567891011121314
<div id="stage1" class="stage active">
    <div class="gift-box" onclick="openGift()">🎁</div>
    <p>Tap the gift to open it!</p>
</div>

<div id="stage2" class="stage">
    <h1>Happy Birthday!</h1>
    <p>Your personalized message here...</p>
    <button onclick="celebrate()">🎉 Celebrate!</button>
</div>

<div id="stage3" class="stage">
    <!-- Confetti + Music celebration -->
</div>

Stage Transitions with CSS

css
123456789101112
.stage {
    display: none;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stage.active {
    display: flex;
    opacity: 1;
    transform: scale(1);
}

JavaScript Flow Control

javascript
123456789101112131415
function openGift() {
    // Animate gift box opening
    document.querySelector(&#039;.gift-box&#039;).classList.add(&#039;opening&#039;);
    
    setTimeout(() => {
        switchStage(&#039;stage1&#039;, &#039;stage2&#039;);
    }, 1000);
}

function switchStage(from, to) {
    document.getElementById(from).classList.remove(&#039;active&#039;);
    setTimeout(() => {
        document.getElementById(to).classList.add(&#039;active&#039;);
    }, 300);
}

Adding Background Music

html
123
<audio id="bgMusic" loop>
    <source src="birthday-song.mp3" type="audio/mpeg">
</audio>
javascript
1234567891011121314
function celebrate() {
    switchStage(&#039;stage2&#039;, &#039;stage3&#039;);
    
    // Start music
    const music = document.getElementById(&#039;bgMusic&#039;);
    music.volume = 0.5;
    music.play().catch(() => {
        // Autoplay blocked — show play button
        showMusicButton();
    });
    
    // Launch confetti
    burstConfetti();
}

> Note: Browsers block autoplay audio. Always provide a user-initiated play button as fallback.

---

🎨 Customization Guide

FeatureHow to Change
Gift emojiChange 🎁 to any emoji
MessageEdit the text in #stage2
MusicReplace birthday-song.mp3 with your file
Confetti colorsEdit the colors array in JS
ThemeChange CSS gradient backgrounds

---

G

About the Author: gs_admin

A senior technical contributor specializing in architectural designs, software optimization, database structures, and developer education. Passionate about writing clean code and sharing engineering knowledge.