Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
    <div class="newsletter-container">
        <div class="offer-badge">🎁 FREE RESOURCE</div>
        <div class="newsletter-header">
            <h2>Get Our Ultimate Social Media Content Calendar</h2>
            <p>Plan your content like a pro with our battle-tested template used by top creators</p>
        </div>
        <div class="lead-magnet-box">
            <h3>What You'll Get:</h3>
            <ul>
                <li>12-month content planning template</li>
                <li>30+ content ideas for any niche</li>
                <li>Engagement tracking spreadsheet</li>
                <li>Best posting times cheat sheet</li>
            </ul>
            <div style="color: #4a5568; font-weight: 600;">Value: $97 - Today: FREE</div>
        </div>
        <form id="newsletterForm" novalidate>
            <div class="form-group">
                <label for="name">Your Name</label>
                <input type="text" id="name" name="name" placeholder="Enter your name" required>
                <div class="error-message" id="nameError">Please enter your name</div>
            </div>
            <div class="form-group">
                <label for="email">Email Address</label>
                <input type="email" id="email" name="email" placeholder="Enter your email" required>
                <div class="error-message" id="emailError">Please enter a valid email address</div>
            </div>
            <button type="submit" class="subscribe-btn">Get Free Access Now</button>
            <div class="guarantee-text">🔒 Your information is secure. We never share your data.</div>
        </form>
        <div class="success-message" id="successMessage">
            <h3 style="color: #38a169; margin-bottom: 1rem;">🎉 Check Your Email!</h3>
            <p>Your Social Media Content Calendar is on its way to your inbox. Please check your email to download your free resource.</p>
        </div>
    </div>
</body>

              
            
!

CSS

              
                * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
        }

        body {
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }

        .newsletter-container {
            background: white;
            padding: 2.5rem;
            border-radius: 16px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            width: 90%;
            max-width: 450px;
        }

        .offer-badge {
            background: #ff6b6b;
            color: white;
            padding: 0.5rem 1rem;
            border-radius: 25px;
            font-size: 0.9rem;
            font-weight: 600;
            display: inline-block;
            margin-bottom: 1rem;
            transform: translateY(-40px);
            margin-bottom: -20px;
            box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
        }

        .newsletter-header {
            text-align: center;
            margin-bottom: 2rem;
        }

        .newsletter-header h2 {
            color: #2d3748;
            font-size: 1.75rem;
            margin-bottom: 1rem;
            line-height: 1.3;
        }

        .newsletter-header p {
            color: #4a5568;
            font-size: 1rem;
            line-height: 1.6;
        }

        .lead-magnet-box {
            background: #f7fafc;
            border: 2px dashed #667eea;
            border-radius: 12px;
            padding: 1.5rem;
            margin-bottom: 2rem;
            text-align: center;
        }

        .lead-magnet-box h3 {
            color: #2d3748;
            font-size: 1.2rem;
            margin-bottom: 0.75rem;
        }

        .lead-magnet-box ul {
            text-align: left;
            list-style-type: none;
            margin: 1rem 0;
        }

        .lead-magnet-box ul li {
            color: #4a5568;
            margin: 0.5rem 0;
            padding-left: 1.5rem;
            position: relative;
        }

        .lead-magnet-box ul li:before {
            content: "✓";
            color: #667eea;
            position: absolute;
            left: 0;
            font-weight: bold;
        }

        .form-group {
            margin-bottom: 1.25rem;
        }

        .form-group label {
            display: block;
            margin-bottom: 0.5rem;
            color: #4a5568;
            font-size: 0.95rem;
            font-weight: 500;
        }

        .form-group input {
            width: 100%;
            padding: 0.875rem;
            border: 2px solid #e2e8f0;
            border-radius: 8px;
            font-size: 1rem;
            transition: all 0.3s ease;
        }

        .form-group input:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        .error-message {
            color: #ff6b6b;
            font-size: 0.85rem;
            margin-top: 0.25rem;
            display: none;
        }

        .subscribe-btn {
            width: 100%;
            padding: 1rem;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 8px;
            font-size: 1.1rem;
            font-weight: 600;
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease;
            box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
        }

        .subscribe-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
        }

        .subscribe-btn:disabled {
            background: #cbd5e0;
            transform: none;
            box-shadow: none;
            cursor: not-allowed;
        }

        .success-message {
            display: none;
            text-align: center;
            color: #38a169;
            background: #f0fff4;
            padding: 2rem;
            border-radius: 8px;
            margin-top: 1rem;
        }

        .loading {
            position: relative;
            pointer-events: none;
        }

        .loading::after {
            content: "";
            position: absolute;
            width: 24px;
            height: 24px;
            top: 50%;
            left: 50%;
            margin: -12px 0 0 -12px;
            border: 3px solid rgba(255, 255, 255, 0.3);
            border-top-color: #ffffff;
            border-radius: 50%;
            animation: loading-spinner 0.8s ease infinite;
        }

        .guarantee-text {
            text-align: center;
            color: #718096;
            font-size: 0.9rem;
            margin-top: 1rem;
        }

        @keyframes loading-spinner {
            to {
                transform: rotate(360deg);
            }
        }
              
            
!

JS

              
                document.addEventListener('DOMContentLoaded', function() {
            const form = document.getElementById('newsletterForm');
            const nameInput = document.getElementById('name');
            const emailInput = document.getElementById('email');
            const nameError = document.getElementById('nameError');
            const emailError = document.getElementById('emailError');
            const submitButton = form.querySelector('button[type="submit"]');
            const successMessage = document.getElementById('successMessage');

            function validateEmail(email) {
                const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
                return re.test(email.toLowerCase());
            }

            function showError(input, errorElement, message) {
                input.style.borderColor = '#ff6b6b';
                errorElement.style.display = 'block';
                errorElement.textContent = message;
            }

            function hideError(input, errorElement) {
                input.style.borderColor = '#e2e8f0';
                errorElement.style.display = 'none';
            }

            nameInput.addEventListener('input', () => {
                hideError(nameInput, nameError);
            });

            emailInput.addEventListener('input', () => {
                hideError(emailInput, emailError);
            });

            form.addEventListener('submit', async function(e) {
                e.preventDefault();
                let isValid = true;

                if (!nameInput.value.trim()) {
                    showError(nameInput, nameError, 'Please enter your name');
                    isValid = false;
                }

                if (!emailInput.value.trim() || !validateEmail(emailInput.value)) {
                    showError(emailInput, emailError, 'Please enter a valid email address');
                    isValid = false;
                }

                if (isValid) {
                    submitButton.classList.add('loading');
                    submitButton.disabled = true;

                    try {
                        await new Promise(resolve => setTimeout(resolve, 1500));
                        form.style.display = 'none';
                        successMessage.style.display = 'block';
                    } catch (error) {
                        console.error('Subscription failed:', error);
                        alert('Something went wrong. Please try again later.');
                    } finally {
                        submitButton.classList.remove('loading');
                        submitButton.disabled = false;
                    }
                }
            });
        });
              
            
!
999px

Console