Skip to content

Age verification in HTML and CSS

A legal-age check window for a wine shop or brewery, accessible, remembered for the session and with the French Evin law notices.

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>Vérification de l’âge</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <div class="mva" data-mva>
        <header class="mva-shop">
script.js
document.querySelectorAll("[data-mva]").forEach((root) => {
  const on = (el, type, fn) => el.addEventListener(type, fn);
  const KEY = "forge-mva-majeur";
  const dialog = root.querySelector("[data-mva-dialog]");
  let confirmed = false;
  try {
    confirmed = sessionStorage.getItem(KEY) === "oui";
  } catch {
    confirmed = false;
  }
  if (!confirmed && !dialog.open) dialog.showModal();
  // The question must be answered: Escape does not skip it.
style.css
:root {
  --mva-bg: #f7f1ec;
  --mva-text: #2a1519;
  --mva-muted: #5c4448;
  --mva-card: #fffdfb;
  --mva-line: #d9c4c8;
  --mva-accent: #7f1d3a;
  --mva-accent-text: #ffffff;
  --demo-bg: #efe6e1;
  --demo-text: #2a1519;
}

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

Modals components in HTML and CSS
  • A search covering the page, with popular suggestions, opened from the navigation bar.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A short form in a window to request a call from an advisor.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A small window asking to confirm an action before running it.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component