Category · Forms Difficulty Level · Intermediate Published on · January 30, 2024

Modern Contact Form

Sleek contact form with floating labels, validation animations, and smooth transitions, perfect for professional websites.

#contact #form #validation #floating-labels #modern

Responsive Design

Yes

Dark Mode Support

No

lines

459

Browser Compatibility

Chrome · Firefox · Safari · Edge

Live Preview

Interact with the component without leaving the page.

450px

HTML

68

lines

CSS

263

lines

JavaScript

128

lines


                <div class="contact-form-container">
  <div class="form-header">
    <h2>Get In Touch</h2>
    <p>We'd love to hear from you. Send us a message and we'll respond as soon as possible.</p>
  </div>
  
  <form class="contact-form" id="contactForm">
    <div class="form-row">
      <div class="form-group">
        <input type="text" id="firstName" name="firstName" required>
        <label for="firstName">First Name</label>
        <span class="form-line"></span>
      </div>
      
      <div class="form-group">
        <input type="text" id="lastName" name="lastName" required>
        <label for="lastName">Last Name</label>
        <span class="form-line"></span>
      </div>
    </div>
    
    <div class="form-group">
      <input type="email" id="email" name="email" required>
      <label for="email">Email Address</label>
      <span class="form-line"></span>
      <span class="error-message" id="emailError"></span>
    </div>
    
    <div class="form-group">
      <input type="tel" id="phone" name="phone">
      <label for="phone">Phone Number (Optional)</label>
      <span class="form-line"></span>
    </div>
    
    <div class="form-group">
      <select id="subject" name="subject" required>
        <option value=""></option>
        <option value="general">General Inquiry</option>
        <option value="support">Support</option>
        <option value="business">Business Partnership</option>
        <option value="other">Other</option>
      </select>
      <label for="subject">Subject</label>
      <span class="form-line"></span>
    </div>
    
    <div class="form-group">
      <textarea id="message" name="message" rows="5" required></textarea>
      <label for="message">Message</label>
      <span class="form-line"></span>
    </div>
    
    <div class="form-group checkbox-group">
      <input type="checkbox" id="newsletter" name="newsletter">
      <label for="newsletter" class="checkbox-label">
        <span class="checkbox-custom"></span>
        Subscribe to our newsletter for updates
      </label>
    </div>
    
    <button type="submit" class="submit-btn">
      <span class="btn-text">Send Message</span>
      <span class="btn-loader">
        <span class="spinner"></span>
      </span>
    </button>
  </form>
</div>

              
68lines
2275characters
HTMLLanguage

Browser Compatibility

Chrome

≥ 50

Firefox

≥ 45

Safari

≥ 10

Edge

≥ 15

Related Code Snippets

Explore template packs

Need larger building blocks? Browse responsive landing pages and component bundles.

Open HTML Template Library →