Skip to content

Product page in HTML and CSS

A complete product page: product views, colors and sizes as radio buttons, a quantity selector and an announced add-to-cart.

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>Fiche produit</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <section class="fp" aria-labelledby="fp-title" data-product>
        <div class="fp__media">
product.js
document.querySelectorAll("[data-product]").forEach((root) => {
  const form = root.querySelector("form");
  const photo = root.querySelector("[data-product-photo]");
  const views = [...root.querySelectorAll("[data-view]")];
  const quantity = form.elements.quantite;
  const status = root.querySelector("[data-product-status]");
  const euros = new Intl.NumberFormat("fr-FR", { style: "currency", currency: "EUR" });
  let view = views[0];

  function render() {
    const glaze = form.querySelector('[name="couleur"]:checked');
    const size = form.querySelector('[name="contenance"]:checked');
style.css
:root {
  --fp-text: #2a1f14;
  --fp-muted: #6b5848;
  --fp-field: #ffffff;
  --fp-line: #e6dccf;
  --fp-accent: #3f2a1a;
  --fp-accent-hover: #2a1b10;
  --fp-accent-text: #ffffff;
  --fp-success: #3d6b35;
  --fp-ring: #3f2a1a;
  --demo-bg: #faf7f2;
  --demo-text: #2a1f14;

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

E-commerce components in HTML and CSS
  • A limited-time offer bar: countdown to a fixed date, one-click copyable promo code and a fallback message once the offer is over.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A sales card showing the discount that grows with the cart amount (-10% from €50, -15% from €100…) with a progress bar towards the next tier.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A Christmas gift guide filtered by budget and theme, with the number of ideas announced and an empty state offering to show everything again.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • The last order dates for delivery before Christmas, per shipping method, with the days left worked out from the visitor’s date.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A cart that shows live how much is left to add for free shipping, with a progress bar and recalculated totals.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A colour and size picker for a product page: the visual, price and stock follow the choice, and sold-out sizes are disabled.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component