Waaplink
← Blog

How to Add a WhatsApp Chat Button to Your Website (HTML + CSS Guide 2026)

Learn how to add a floating WhatsApp chat button to your website with HTML, CSS, and JavaScript. Step-by-step guide with copy-paste code for any site builder.

2026-06-29

How to Add a WhatsApp Chat Button to Your Website (HTML + CSS Guide 2026)

A WhatsApp chat button on your website turns passive visitors into real-time conversations. One tap and they're chatting with your business β€” no forms, no email, no friction.

This guide covers everything: from a simple inline HTML button to a floating widget with animations, plus how to add it to WordPress, Shopify, Wix, or any plain HTML site.

Why a WhatsApp button boosts conversions

| Metric | Without WhatsApp | With WhatsApp |

|--------|-----------------|---------------|

| Contact rate | 5–15% (forms) | 40–60% (click-to-chat) |

| Response time | 12–24 h (email) | 2–5 min |

| Open rate | 20–30% (email) | 98% |

| Customer satisfaction | Baseline | +25% NPS |

A WhatsApp button captures visitors at the moment of interest. They don't fill a form, wait for a reply, or switch apps β€” they just tap and talk.

Option 1: Simple inline button (HTML)

Paste this anywhere in your HTML for a clickable WhatsApp button:

<a href="https://wa.me/34612345678?text=Hi%2C%20I%20have%20a%20question"

style="background-color:#25D366; color:#fff; padding:14px 28px;

border-radius:8px; text-decoration:none; font-weight:600;

font-size:16px; display:inline-block;">

πŸ’¬ Chat on WhatsApp

</a>

Replace 34612345678 with your business number (country code + number, no plus sign).

Pre-filled message matters. Without ?text=, the user opens an empty chat box and many won't type. Good examples:
  • ?text=Hi%2C%20I%27d%20like%20a%20quote (services)
  • ?text=Hi%2C%20I%20have%20a%20question%20about%20a%20product (e-commerce)
  • ?text=Hi%2C%20I%27d%20like%20to%20book%20an%20appointment (booking)

Option 2: Floating WhatsApp button (CSS widget)

A floating button stays in the bottom-right corner on every page β€” the most popular design. Here's the full code:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<style>

.wa-float {

position: fixed;

bottom: 24px;

right: 24px;

z-index: 1000;

}

.wa-float a {

display: flex;

align-items: center;

justify-content: center;

width: 60px;

height: 60px;

background: #25D366;

color: #fff;

border-radius: 50%;

text-decoration: none;

font-size: 30px;

box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);

transition: transform 0.2s ease;

}

.wa-float a:hover { transform: scale(1.1); }

@keyframes pulse {

0% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5); }

70% { box-shadow: 0 0 0 14px rgba(37, 211, 102, 0); }

100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }

}

.wa-float a { animation: pulse 2s infinite; }

</style>

</head>

<body>

<div class="wa-float">

<a href="https://wa.me/34612345678?text=Hi%2C%20I%20need%20help"

target="_blank" rel="noopener noreferrer"

aria-label="Chat on WhatsApp">πŸ’¬</a>

</div>

</body>

</html>

Customizing the floating button

  • Change position: swap right: 24px for left: 24px.
  • Resize: adjust width, height, and font-size proportionally.
  • Change color: replace #25D366 with your brand accent.
  • Remove pulse: delete the @keyframes and animation lines.

Show button after scroll (JavaScript)

For a cleaner hero section, show the button only after the visitor scrolls past 400 px:

<script>

const btn = document.querySelector('.wa-float');

btn.style.display = 'none';

window.addEventListener('scroll', () => {

btn.style.display = window.scrollY > 400 ? 'block' : 'none';

});

</script>

Adding WhatsApp to popular site builders

| Platform | Where to paste |

|----------|---------------|

| WordPress | Paste CSS in "Additional CSS". Add HTML with a "Custom HTML" block in footer or via a plugin like Insert Headers and Footers. |

| Shopify | Edit theme.liquid β†’ paste HTML before and CSS in theme.css. |

| Wix | Add an "HTML iframe" embed from the Add menu. |

| Webflow | Add an "Embed" element to the page footer, paste code, set visible on all pages. |

| Static HTML | Copy the floating button code into every page's footer or use a templating engine. |

Common mistakes to avoid

| Mistake | Fix |

|---------|-----|

| No pre-filled message | Always add ?text= with a friendly prompt |

| Wrong number format | Use country code + number, no +, no spaces: 34612345678 |

| Missing target="_blank" | User leaves your site; add target="_blank" rel="noopener noreferrer" |

| z-index too low | Set z-index: 1000 or higher |

| Linking a personal number | Use a dedicated WhatsApp Business number |

Track clicks on your WhatsApp button

  • UTM-style messages. Use different ?text= per page: ?text=Hi%20from%20homepage vs ?text=Hi%20from%20pricing. Check first message in your inbox.
  • Google Analytics. Wrap the button click: gtag('event', 'whatsapp_click').
  • Waaplink short links. Create a trackable short link per page at Waaplink's Link Generator.

Generate your button in seconds

Instead of writing code from scratch, use the free WhatsApp Button Generator:

  • Enter your phone number and pre-filled message.
  • Choose a style (rounded, square, floating, inline).
  • Copy the ready-to-use HTML snippet.
  • Paste into your website.

No signup, no watermark, no email required.

Summary

A WhatsApp chat button is one of the highest-ROI changes you can make to your website. It takes 5 minutes to add yet can double your contact rate.

Key takeaways:

πŸ‘‰ Generate your WhatsApp button now β†’


Related tools: Send WhatsApp Without Saving Contact Β· WhatsApp Link Generator Β· WhatsApp QR Code Generator