DEV3 Technologies home

Coming-soon page with countdown

A full-screen coming-soon layout with a live day, hour, minute and second countdown to a launch date.

Tailwind CSSLayoutscountdowncoming-soonlaunchtimer

Live preview

Code

<main class="grid min-h-screen place-items-center bg-slate-950 px-4 text-center text-white">
  <div>
    <p class="text-sm font-semibold uppercase tracking-widest text-indigo-300">Acme Studio</p>
    <h1 class="mt-4 text-balance text-4xl font-bold sm:text-6xl">Something new is on its way</h1>

    <time id="launch" datetime="2027-01-15T09:00:00+00:00" data-launch="2027-01-15T09:00:00+00:00"
      class="mt-10 grid grid-cols-4 gap-3 sm:gap-6">
      <div class="rounded-xl bg-white/10 p-4"><span id="cd-d" class="block text-3xl font-bold tabular-nums sm:text-5xl">--</span><span class="text-xs text-slate-300">Days</span></div>
      <div class="rounded-xl bg-white/10 p-4"><span id="cd-h" class="block text-3xl font-bold tabular-nums sm:text-5xl">--</span><span class="text-xs text-slate-300">Hours</span></div>
      <div class="rounded-xl bg-white/10 p-4"><span id="cd-m" class="block text-3xl font-bold tabular-nums sm:text-5xl">--</span><span class="text-xs text-slate-300">Minutes</span></div>
      <div class="rounded-xl bg-white/10 p-4"><span id="cd-s" class="block text-3xl font-bold tabular-nums sm:text-5xl">--</span><span class="text-xs text-slate-300">Seconds</span></div>
    </time>

    <p id="cd-live" class="sr-only" aria-live="polite"></p>
    <p id="cd-done" class="mt-10 hidden text-xl">We have launched. Welcome!</p>
    <noscript><p class="mt-6 text-slate-300">We launch on 15 January 2027.</p></noscript>
  </div>
</main>

How it works

What it solves

A pre-launch page should state the date and keep visitors engaged. A countdown does that, but naive timers drift, show negative numbers after launch or announce every second to screen readers. This one avoids those problems.

How it works

The target time is stored in a data-launch attribute on a time element as an ISO string, so the date is visible to crawlers and editable without touching code. The script computes the remaining milliseconds from Date.now() on every tick instead of subtracting one each interval, so a throttled background tab catches up instantly when it returns. Days, hours, minutes and seconds come from integer division and are padded with padStart. Four cells use tabular-nums so digits do not jitter. When the difference reaches zero the interval clears and a message replaces the digits. Only a visually hidden summary is in a live region, updated once per minute, so assistive technology is not flooded.

Adapting it

Change the attribute for a new date. Add a signup form below the timer, or swap the background for a photo with an overlay. For time zones, write the ISO string with an explicit offset.

Pitfalls

  • Without an offset, the browser reads the date in the visitor's time zone.
  • Do not stack two intervals if the script is loaded twice.
  • Provide a fallback sentence for visitors without JavaScript.

How to use it

  1. Save coming-soon.html as your landing page and load countdown.js with defer.
  2. Set the data-launch value on the time element to your ISO date with offset.
  3. Edit the heading and message copy.
  4. Optionally add a form for notifications below the timer.

Licence: DEV3 Snippet Licence. Free to use, change and ship in personal and commercial projects. Attribution is appreciated, not required. Please do not redistribute snippets as a collection.

Related snippets