Animated ellipsis

How to make an animated ellipsis, the "Loading..." dots effect, with CSS or JavaScript without altering the meaningful text, plus checks for layout, accessibility and reduced motion.

What an animated ellipsis does to your text

An animated ellipsis is the familiar effect where dots appear one after another after a short status label, such as "Loading" becoming "Loading.", "Loading.." and "Loading..." in a loop. It tells the reader that a process is still running. The input is a fixed piece of text (the label). The output is a visual effect layered on that text. Done well, the label itself never changes. Only the trailing dots move.

That scope matters. The animation is presentation, not content. The meaningful words should stay intact for copying, searching, translation and screen readers, and the dots should be treated as decoration. Every method below keeps the label and the animated part separate for this reason.

Three periods or one ellipsis character?

Two different things are both called an ellipsis. One is three separate full stops: "..." (U+002E FULL STOP, typed three times). The other is a single typographic character: "…" (U+2026 HORIZONTAL ELLIPSIS). They can look similar, but they behave differently in an animation.

  • Three periods "...": each dot is its own character, so each one can be shown, hidden or timed on its own. This is the practical choice for a dot-by-dot animation.
  • One character "…": the three dots are a single glyph. You cannot reveal its dots individually without tricks such as clipping, and those depend on the font's glyph shape.
  • Watch for automatic replacement: some editors, CMS typography filters and "smart punctuation" features silently turn "..." into "…". If your per-dot animation suddenly shows all dots at once, check whether the three periods were merged into one character.

Method 1: CSS only, with separate dots (recommended for web pages)

This approach puts each dot in its own element and fades them in sequence. Because the dots are always present and only their opacity changes, the line keeps the same width and the surrounding text does not jump.

Step 1. Mark up the label and the dots separately. The example below hides the dots from assistive technology with aria-hidden, so a screen reader announces only the word "Loading".

<span class="loading" role="status">
  Loading<span class="dots" aria-hidden="true"><span>.</span><span>.</span><span>.</span></span>
</span>

Step 2. Add the animation. The durations and delays below are illustrative starting values, not measured recommendations. Adjust them until the rhythm looks right to you.

.dots span {
  opacity: 0;
  animation: ellipsis-dot 1.2s infinite;
}

.dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ellipsis-dot {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 0; }
}

Step 3. Respect the user's motion preference. The prefers-reduced-motion media query lets you show static dots to people who have asked their system to minimize animation.

@media (prefers-reduced-motion: reduce) {
  .dots span {
    animation: none;
    opacity: 1;
  }
}

Result: the text reads "Loading..." with the three dots pulsing in sequence. The word "Loading" is never rewritten. With reduced motion turned on, the reader sees a plain, static "Loading...".

Method 2: JavaScript that cycles the dots

If you want the classic look where dots are added one at a time (empty, one, two, three, then repeat), a short script can rewrite only the dots element. Keep the label in its own text node so the script never touches it.

<span class="loading">Loading<span class="dots" aria-hidden="true"></span></span>

<script>
  const dots = document.querySelector('.dots');
  let count = 0;

  const timer = setInterval(() => {
    count = (count + 1) % 4;
    dots.textContent = '.'.repeat(count);
  }, 400);

  // When the task finishes:
  // clearInterval(timer);
</script>

Two caveats apply to this method. First, the dots element changes width as dots are added, which can nudge any text that follows. Giving it a fixed width, for example display: inline-block with a width wide enough for three dots, prevents that. Second, because the script really changes text, never place the changing dots inside a live region. Otherwise a screen reader may announce every update. The aria-hidden attribute in the example avoids that. Also remember to stop the timer when the work finishes, and consider checking prefers-reduced-motion in script before starting it.

Choosing between the methods

  • Use the CSS method when you want no script, a stable layout and an easy reduced-motion fallback.
  • Use the JavaScript method when you specifically want dots to be added one by one, or when the animation must start and stop with application state.
  • Use a plain, static "..." or "…" when the status is brief or motion adds nothing. The meaning is the same.

How to verify the result

  • Layout: watch the line for a few cycles. Text after the dots should not shift horizontally.
  • Content: inspect the element or select the text. The label (for example "Loading") should be unchanged, with exactly the characters you intended. Confirm the dots are three U+002E periods if you animate them individually.
  • Screen reader: the label should be announced once, not repeatedly with each dot change.
  • Reduced motion: turn on your operating system's reduce-motion setting and reload. The dots should be static.
  • Cleanup: when the task completes, the animation should stop or the element should be replaced with the final message.
  • Browsers: test in the browsers you support. This guide is based on general CSS and JavaScript principles. It does not include browser compatibility tables or performance measurements, so confirm behavior in your own targets.