A WhatsApp button on a website is a plain WhatsApp link to https://wa.me/ followed by your phone number in full international format, styled to look like a button. It needs no plugin, no widget script and no account beyond the WhatsApp account on your number; a few lines of HTML and CSS cover it, a floating WhatsApp button included (that code is in Step 3).
https://wa.me/12025550143
That's the whole trick (the number is from the US range reserved for fiction). It's the same idea as the mailto: link of the 1990s, pointed at a chat app, and like mailto: it breaks quietly when the details are off: a number in the wrong format, a pre-filled message cut in half, a button nobody can read. We tested the link formats in desktop Chrome on November 21, 2026.
What a WhatsApp button on a website does
A WhatsApp button opens a chat with your number. WhatsApp calls the feature click to chat, and its help page says it lets you "begin a chat with someone without having their phone number saved", as long as they "have an active WhatsApp account".
On a phone, the link opens the WhatsApp app with a chat to your number. On a computer, it opens a WhatsApp page that offers the desktop app or WhatsApp Web.
Step 1: Make the WhatsApp link for your website (wa.me)
To create a WhatsApp chat link for your number, use https://wa.me/<number>, where the number is "a full phone number in international format"; WhatsApp's click-to-chat help page (checked November 21, 2026) adds "Omit any zeroes, brackets, or dashes". Its examples: use https://wa.me/1XXXXXXXXXX, don't use https://wa.me/+001-(XXX)XXXXXXX.
The step people miss is the trunk zero, the 0 you dial at home before a mobile number, which disappears once the country code goes in front.
| Country | Written locally | In the link |
|---|---|---|
| India (+91) | 0XXXXX XXXXX | 91XXXXXXXXXX |
| Pakistan (+92) | 03XX XXXXXXX | 923XXXXXXXXX |
| Egypt (+20) | 01X XXXX XXXX | 201XXXXXXXXX |
| Kenya (+254) | 07XX XXXXXX | 2547XXXXXXXX |
| Nigeria (+234) | 080X XXX XXXX | 23480XXXXXXXX |
| US (+1) | (202) 555-0143 | 12025550143 |
Other prefixes, such as Kenya's 01XX or Nigeria's 070, 081 and 090, follow the same rule: drop the leading 0.
Paste the link into a browser first. In our test, a correct link opened a WhatsApp page reading "Chat on WhatsApp with +1 202-555-0143". With the zero left in or the country code missing, the page still loaded but showed raw digits with no plus, the hint that WhatsApp didn't recognize the number. Spaces, dashes or brackets got "404. This page doesn't exist." A single leading plus happened to work, but WhatsApp's example leaves it out, so we would too.
The older https://api.whatsapp.com/send?phone= form is where wa.me forwarded us, so both reach the same page, and link generator sites build this same URL for you.
The WhatsApp Business app also gives you a short link (wa.me/message/ plus a code) that can go in the button instead and keeps your number off the page; see the privacy section.
Add a pre-filled message with ?text=
Add ?text= and a message, and WhatsApp puts it in the visitor's text box, ready to send:
https://wa.me/12025550143?text=Hi
WhatsApp's help page asks for "urlencodedtext", so characters that mean something in a URL get codes: space %20, & %26, ? %3F, # %23, line break %0A.
The & is the one that bites. In our test, an unencoded "Cake & coffee for 2?" arrived as just "Cake", because a raw & starts a new URL parameter. Encoded, the whole sentence came through. Apostrophes are fine as they are; WhatsApp's own example keeps the one in "I'm".
The easy way to encode is your browser's console (right-click a page, Inspect, Console):
encodeURIComponent(
"Hi, is the cake ready?")
That returns Hi%2C%20is%20the%20cake%20ready%3F, which goes after ?text=.
The message also doubles as the cheapest tracking there is: "Hi, I saw your price list on the website" tells you where the chat came from, and a different message per page tells you which page.
Step 2: Add a WhatsApp button with HTML (copy and paste)
Here's the WhatsApp button HTML code: a real <a> link with visible text, so screen readers announce it as a link and the keyboard can reach it. No JavaScript:
<a class="wa-button"
href="https://wa.me/12025550143?text=Hi">
Chat on WhatsApp
</a>
The CSS goes in your stylesheet or a <style> block in the page's <head>:
.wa-button {
display: inline-flex;
align-items: center;
min-height: 44px;
padding: 10px 20px;
border-radius: 999px;
background: #25D366;
color: #111B21;
font-weight: 600;
text-decoration: none;
}
.wa-button:hover {
background: #1EBE5D;
}
.wa-button:focus-visible {
outline: 3px solid #111B21;
outline-offset: 3px;
}
Dark text on the green. #25D366 is the widely copied WhatsApp green (Meta's brand page publishes no hex code). White text on it measures 1.98:1 with the WCAG contrast formula, and WCAG 1.4.3 asks for 4.5:1 for normal text; bold 16px isn't "large" text (that starts around 18.5px bold). Near-black #111B21 on the same green measures 8.8:1, and 7.1:1 on the hover green. For white text, use a dark green such as #075E54 (7.7:1). A popular snippet from a widget vendor's guide uses white on #25D366 with a #128C7E hover: 1.98:1 and 4.14:1, so both states fall short. WCAG doesn't excuse brand colors either: low contrast "due to corporate identity or brand guidelines is not exempted". We computed these ratios on November 21, 2026; re-check any color you change.
At least 44 by 44 pixels. WCAG 2.5.5 asks for targets of "at least 44 by 44 CSS pixels" at its strict AAA level, and 2.5.8 sets the AA floor at 24 by 24. The min-height and padding clear 44.
A visible focus ring. WCAG 2.4.7 wants keyboard focus visible and counts removing the focus indicator as a failure, so don't set outline: none unless you replace it with something just as visible. On a dark page, use a light outline color.
The wording, and the official button. WhatsApp's brand guidelines say never to use "WhatsApp" as a verb, so "Chat on WhatsApp" beats "WhatsApp us". For the official artwork, the click-to-chat help page offers a "Chat on WhatsApp" button to download, in green or white and three sizes, with the instruction "Use the button as is": put the image inside the same <a> with alt="Chat on WhatsApp". It's English only for now, so a site in Arabic or Urdu is better off with a text button in its own language.
Step 3: Add a WhatsApp floating button (HTML and CSS)
A WhatsApp floating button stays in the bottom corner as the page scrolls. It reuses the class above and adds one:
<a class="wa-button wa-float"
href="https://wa.me/12025550143?text=Hi">
Chat on WhatsApp
</a>
.wa-float {
position: fixed;
right: 16px;
bottom: calc(16px +
env(safe-area-inset-bottom));
z-index: 50;
box-shadow:
0 2px 8px rgb(0 0 0 / 0.3);
}
env(safe-area-inset-bottom) clears the iPhone home bar on pages whose viewport tag uses viewport-fit=cover; elsewhere it's zero. If you shrink the button to an icon-only circle, add aria-label="Chat on WhatsApp" to the <a> and keep it at least 44 pixels across.
Floating buttons have traps of their own:
- Cookie banners usually sit at the bottom too. Keep the button's
z-indexbelow the banner's so the banner stays on top. - The footer's last link can end up under the button. Give the footer about 80px of bottom padding.
- Other corner buttons, such as "back to top", will fight it. Move one.
- Animation. If you want the popular pulse, wrap it in a
prefers-reduced-motion: no-preferencemedia query.
Step 4: Add the button to an AI-made page or an HTML file
The HTML goes inside <body>: the plain button wherever it fits (a contact section, the header), the floating one just before </body>, once per page. If your site has a shared footer file, put it there.
A hand-written or template site: open index.html in a text editor, paste, save, and open the file in a browser to check. If the whole site is one file, see the guide to hosting an HTML file.
A page an AI made: hand it the job with the link already built:
Add a "Chat on WhatsApp" button to
every page. Use a plain <a> link to
https://wa.me/12025550143?text=Hi
No JavaScript, no widget. Dark text
#111B21 on #25D366, at least 44px
tall, with a visible focus outline.
Also add a floating copy, bottom
right, above the iPhone safe area.
Swap in your link and read what comes back: AI tools like to "help" with a widget script or an icon library, so ask for any new <script> tag to be removed. For sites built with Claude, see the guide to building a website with Claude; for Lovable, Bolt or v0 exports, the vibe coding guide.
Step 5: Put the updated site online on Hostsmith
The button only reaches customers once the updated page is live on the site they already visit. Hostsmith hosts static sites and single files, which covers a hand-written page and the HTML an AI builder exports.
In the dashboard, drop your zipped folder, or the single HTML file for a one-page site. The trap when updating: a new upload replaces all of the site's files at the same address, so zip the whole site folder each time, including the pages you didn't touch, or they disappear. The guide to publishing a website from a folder covers the zip and the update.
A business site on its own domain needs Pro ($15 a month billed yearly, $21 billed monthly; prices, as of November 2026) or a higher plan; the Free plan is one site and 5 MB on a your-site.us.hostsmith.link address, with a Hostsmith watermark.
Step 6: Test your WhatsApp button on a phone and a desktop
The bare link can be tried on a phone any time; the button is worth checking once the page is live:
- Phone with WhatsApp: tap the button. The app should open a chat with your number and the message in the text box.
- Desktop: click it. In our desktop Chrome test,
wa.meforwarded to a WhatsApp page with the number (plus sign and country code), the message, "Open app", "Continue to WhatsApp Web" and a download link. - Keyboard: Tab to the button. The focus ring should show, and Enter should open the link.
- About 390px wide: the floating button shouldn't cover the cookie banner, the menu or the footer.
- A real message: send one from a second phone and check it arrives.
Why is my WhatsApp click-to-chat link invalid?
Almost always the number: it isn't in full international format (country code, no leading zero, digits only), or it isn't registered on WhatsApp. The usual causes:
- The format: a leading zero after the country code, a missing country code, or spaces, dashes and brackets (see Step 1's table and test).
- A number without WhatsApp. The web page doesn't check; it happily displayed our fictional 555 number. Only the app or WhatsApp Web finds out, hence the phone test.
- A broken
?text=, where a raw&,?or#cuts the message or mangles the link. - Invisible characters copied from a contact card along with the number.
WhatsApp button or contact form? Choose by where your customers are
It depends on how your customers already reach businesses like yours, and plenty of sites do best with both.
A WhatsApp button suits a business that already works on WhatsApp: quick questions, orders, a photo of what someone wants, a reply the same afternoon. Where people already message shops that way, customers expect it.
A form suits other jobs: requests on record in your inbox, email alerts, spam filtering, fixed fields like a date or a budget, and customers who don't use WhatsApp. A static site needs a form service such as Formspree or Tally to receive the entries; the guide to an AI landing page on your own domain shows the setup.
Side by side often works best: a form for quotes and bookings, the button for "are you open on Sunday?".
Do you need a WhatsApp widget or plugin?
For one business and one number, a plain link covers it. Widgets earn their place when you need more.
Elfsight's widget page is typical of what they add: a chat window with a welcome message and stated reply time, rules for when it pops open (page load, time on page, scroll position, exit intent), and placement options. Whatsform's shows a short form first, so you know who's writing.
The costs: a third-party script on every page, loaded from the vendor's servers (worth checking against your privacy notice and cookie banner), while the plain link loads nothing from WhatsApp until someone clicks; limits and branding on no-cost tiers (Elfsight's Free plan is 200 views a month with Elfsight branding, and going over will "temporarily deactivate" the widget until the monthly count resets; paid plans start at $5 a month billed yearly, checked November 21, 2026); and one more account to keep paid up. If several people share incoming chats, a widget or the WhatsApp Business Platform is the right tool. WordPress plugins exist too, but a site moved off WordPress or written by hand has nothing for a plugin to plug into.
Privacy: your WhatsApp number is public
The number in a wa.me/<number> link sits in the page source, readable by anyone, including scrapers that collect phone numbers from websites. Expect some spam, and use a business number for this (a second SIM with the WhatsApp Business app) rather than your personal one.
That same app has the tidier fix: a short link. WhatsApp's short links help page (checked November 21, 2026) says one "is automatically generated when you create an account on the WhatsApp Business app". It's under the app's Tools, where you can copy it for your website and set a default message that customers can edit before sending. Meta's developer docs say a short link "masks the phone number"; the Business Platform API can create them too.
Put the short link in the button's href and set the message in the app instead of with ?text=. It keeps the number out of your page; don't count on it hiding the number from people who actually message you. Opened in a browser, it leads to a page with your business information, plus your profile picture if your privacy settings show it to everyone.
Scrambling the number with JavaScript only slows the laziest scrapers, since the link has to turn back into the number to work.
Frequently asked questions
How do I create a WhatsApp share button?
Leave the number out: https://wa.me/?text= plus your encoded message or page address. WhatsApp's help page says the visitor is then "shown a list of contacts" to send it to.
Does a WhatsApp button cost anything?
No: the link is a plain URL with no sign-up beyond WhatsApp itself, and Meta's paid pricing is for the WhatsApp Business Platform, which a link doesn't use.
Does it work if the visitor doesn't have WhatsApp?
They reach WhatsApp's page, which offers WhatsApp Web and a download, but they need an account to chat, so keep an email address or a form on the page as well.
Can I add more than one number?
Yes, as separate links with clear labels ("Orders", "Support"). Automatic routing between people is widget territory.
Why the plain link lasts
One <a> tag, a correctly formatted number and about twenty lines of CSS will outlast most of the widgets built on top of them, much as the mailto: link has outlasted a generation of contact plugins. Get the number right, encode the message, pick colors people can read, and test on a real phone.
If you run your own small-business site and want a simple home for it on your own domain, see small business website hosting.