Skip to content

Social media share buttons in HTML and CSS

A row of buttons to share the page on Facebook, LinkedIn, WhatsApp or by email, with a copy-link button and no third-party script.

Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in HTML and CSS

index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Boutons de partage sur les réseaux sociaux</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <div class="bprs" data-bprs data-bprs-title="Entretenir une terrasse en bois avant l’hiver" role="group" aria-labelledby="bprs-titre">
        <div class="bprs-head">
script.js
document.querySelectorAll("[data-bprs]").forEach((root) => {
  const on = (el, type, fn) => el.addEventListener(type, fn);
  const offs = [];
  const field = root.querySelector("[data-bprs-field]");
  const fallback = root.querySelector("[data-bprs-fallback]");
  const copy = root.querySelector("[data-bprs-copy]");
  const label = root.querySelector("[data-bprs-label]");
  const status = root.querySelector("[data-bprs-status]");
  const canonical = document.querySelector('link[rel="canonical"]')?.href;
  // The address written in the markup stays the shared one on a local file or a sandboxed preview.
  const page = location.protocol.startsWith("http") ? location.href.split("#")[0] : "";
  const url = root.dataset.bprsUrl || canonical || page || field.value;
style.css
:root {
  --bprs-card: #ffffff;
  --bprs-text: #1c2430;
  --bprs-muted: #4f5b6b;
  --bprs-line: #d5dbe3;
  --bprs-btn: #f4f6f9;
  --bprs-hover: #e9eef5;
  --bprs-focus: #1d4ed8;
  --bprs-facebook: #0b5fcc;
  --bprs-linkedin: #0a66c2;
  --bprs-whatsapp: #0f7b3f;
  --bprs-mail: #9a3412;

Free component: copy it freely, including for commercial projects.

Buttons components in HTML and CSS
  • Toggle heart buttons that count favourites, remember them between visits and announce them to screen readers.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A button that adds an event to Google Calendar, Outlook or any calendar through an .ics file, with no third-party service.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A button that copies an IBAN, a reference, an address or a promo code and confirms "Copied", on screen and to screen readers.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A WhatsApp button pinned to the bottom of the screen that opens a welcome bubble with common topics and a pre-filled message, with no third-party widget.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A bar pinned to the bottom of mobile screens with Call and Directions buttons and a live open-now status, built for trades and local shops.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Circular icon buttons with an accessible tooltip on hover and focus.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component