Skip to content

Table with editable cells in HTML and CSS

A table whose values are edited in place with mouse or keyboard: Enter saves, Escape cancels, input is checked and the change announced.

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>Tableau à cellules modifiables</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <section class="tcm" data-tcm aria-labelledby="tcm-titre">
        <p class="tcm-eyebrow">Boulangerie Lefèvre · fournée de demain</p>
script.js
document.querySelectorAll("[data-tcm]").forEach((root) => {
  const on = (el, type, fn) => el.addEventListener(type, fn);
  const status = root.querySelector("[data-tcm-status]");
  const error = root.querySelector("[data-tcm-error]");

  root.querySelectorAll("[data-tcm-cell]").forEach((cell) => {
    const show = cell.querySelector("[data-tcm-show]");
    const input = cell.querySelector("[data-tcm-input]");
    const name = cell.parentElement.querySelector("th").textContent.trim();
    const label = input.getAttribute("aria-label").split(",")[0];
    const decimal = cell.dataset.tcmMode === "decimal";
    let editing = false;
style.css
:root {
  --tcm-card: #ffffff;
  --tcm-text: #221c16;
  --tcm-muted: #5a4f43;
  --tcm-line: #e3dacd;
  --tcm-hover: #f6efe4;
  --tcm-accent: #9a3412;
  --tcm-error: #b91c1c;
  --demo-bg: #f0e9de;
  --demo-text: #221c16;
}

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

Data tables components in HTML and CSS
  • A documentation table showing where a kit or component has been tested (static HTML, WordPress, Elementor, Webflow, v0…), with status, last test date and a remark, filterable by status.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A table of the towns and postcodes a tradesperson covers, with response time and travel fee, filtered by search and by zone.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A timetable table sorted by column and filtered with level and free-place chips, whose rows each become a card on phones.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A filterable table whose visible rows export in one click to a CSV file that opens cleanly in Excel or LibreOffice.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A price table by service: one package to pick, options to tick, and the total with the estimated time recalculated on every click.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A product spec sheet as two-column tables in native collapsible sections, with a button to open or close them all.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component