How to Make WhatsApp Sticky Icon with CSS

In today’s digital age, having an engaging and user-friendly website is essential. One way to enhance user experience is by adding useful features, such as a WhatsApp sticky icon, to your site. This icon allows visitors to easily contact you through WhatsApp, making communication more convenient. In this article, we’ll walk you through the process of creating a WhatsApp sticky icon using CSS, complete with detailed code snippets. Let’s get started!

Certainly! Let’s delve into more detail about how to create a WhatsApp sticky icon with CSS.

1. Introduction

In the digital era, ensuring smooth and convenient communication with your website’s visitors is crucial. One effective way to achieve this is by adding a WhatsApp sticky icon to your website. This icon remains visible as users scroll through your content, allowing them to easily initiate a conversation with you via WhatsApp. In this detailed guide, we’ll explore each step of creating a WhatsApp sticky icon using CSS, complete with in-depth code snippets and explanations.

2. Prerequisites

Before we embark on the coding journey, let’s ensure you have everything you need:

  • Basic HTML and CSS knowledge: You should be familiar with HTML and CSS fundamentals.
  • Code editor: Have a code editor of your choice installed on your computer.
  • Access to your website’s code: You’ll need access to the HTML and CSS files of your website.

3. HTML Structure

We’ll begin by constructing the HTML structure for our WhatsApp sticky icon. This is a fundamental step in creating any webpage element. Here’s a simplified HTML structure:

<div class="whatsapp-container">
  <a href="#" class="whatsapp-icon">
    <img src="whatsapp-icon.png" alt="WhatsApp Icon">
  • We create a container div with the class “whatsapp-container” to hold our WhatsApp icon.
  • Inside the container, we have an anchor (<a>) element with the class “whatsapp-icon” to wrap our WhatsApp icon image.
  • The image (<img>) element represents the WhatsApp icon itself, with a source (src) attribute pointing to the icon image file.

4. Styling the WhatsApp Icon

Now, let’s style the WhatsApp icon using CSS to give it the desired appearance. We’ll make it circular, set its position, and apply some padding:

.whatsapp-icon {
  background-color: #25d366; /* WhatsApp green color */
  padding: 10px;
  border-radius: 50%;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  • We set the background color to WhatsApp’s distinctive green color.
  • Applying padding ensures some space around the icon.
  • Using border-radius: 50%;, we make the icon circular.
  • position: fixed; keeps the icon in a fixed position relative to the viewport, ensuring it remains visible while scrolling.

5. Making the Icon Sticky

To make our WhatsApp icon sticky, we use the CSS property position: fixed;. This property locks the icon’s position on the screen, so it doesn’t scroll with the rest of the content.

6. Adding WhatsApp Link

To make the icon functional, replace the href="#" attribute with a link to your WhatsApp chat. WhatsApp provides a URL format for this purpose: Replace “YOUR_PHONE_NUMBER” with your actual phone number, including the country code.

7. Testing and Troubleshooting

After implementing the code, thorough testing is essential. Here are some troubleshooting steps:

  • Check for any typos or syntax errors in your code.
  • Ensure the WhatsApp link is correctly formatted.
  • Adjust the icon’s position, size, or styling if needed to fit your website’s design.

8. Best Practices

To provide the best user experience, follow these best practices:

  • Keep the WhatsApp icon small and unobtrusive.
  • Test the icon’s appearance and functionality on various devices for responsiveness.
  • Optimize your website’s performance to prevent any lag caused by additional elements.

9. Conclusion

Incorporating a WhatsApp sticky icon into your website is a valuable enhancement, offering users an easy and convenient way to connect with you. By following the steps outlined in this guide, you can create a seamless user experience that encourages visitors to engage with you via WhatsApp.

Also, you can download the code in a pdf file. Here is the pdf file,


What is a WhatsApp sticky icon?

A WhatsApp sticky icon is a small, fixed-position icon on a website that enables users to initiate a conversation with the site owner via WhatsApp. It remains visible as users scroll through the content.

Do I need any special software to implement this?

No, you only need a basic understanding of HTML and CSS, along with access to your website’s code.

Can I customize the appearance of the icon?

Certainly! You can customize the icon’s size, color, and shape to match your website’s design.

How do I make the icon responsive?

To ensure the icon looks and functions well on different screen sizes, use CSS media queries to adjust its size and position accordingly.

Is this method SEO-friendly?

Yes, this method is SEO-friendly as long as you don’t overuse sticky elements on your site. Google takes user experience into account when ranking websites, so when used appropriately, a WhatsApp sticky icon can contribute positively to SEO efforts.

Leave a Comment