HTML Code for Blinking Text: Easy Guide for Beginners

Key takeaways

  • The <blink> tag no longer works. Firefox, the last browser to support it, removed it in version 23 in August 2013. The HTML Standard lists it as an obsolete element that authors must not use.
  • text-decoration: blink does nothing in current browsers. The value is still accepted, but the major browsers ignore it.
  • The reliable way to get the effect is a CSS @keyframes animation, which changes the text’s opacity on a timer.
  • Blinking has accessibility rules. Under WCAG 2.2.2 (Level A), blinking that lasts more than five seconds needs a way to pause, stop or hide it. Under 2.3.1 (Level A), nothing may flash more than three times in any one-second period.
  • Respect prefers-reduced-motion. Turn the animation off for visitors who have asked their device for less motion.
  • For most pages, don’t blink at all. A static highlight, a bold label or a colored badge gets attention without the drawbacks.

People who search for “html for blinking text” usually expect a tag, and the old one was <blink>. That tag is gone from every browser that matters, so a page that relies on it simply shows ordinary text. What follows is how to get the same visual effect today with CSS, how to add a pause control when the effect has to run longer, and how to do it without harming readers who are sensitive to motion. Facts and browser behavior were checked on 25 November 2026.

The short answer: copy-paste code for blinking text

Save this as an .html file and open it in any current browser. The text blinks four times, then stays visible, and visitors who prefer reduced motion see a static highlight instead.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Blinking text example</title>
  <style>
    @keyframes blink {
      50% { opacity: 0; }
    }

    .blink {
      animation: blink 1s step-end 4;
    }

    @media (prefers-reduced-motion: reduce) {
      .blink {
        animation: none;
        background: #fff3b0;
      }
    }
  </style>
</head>
<body>
  <p>Sale ends <span class="blink">tonight at midnight</span>.</p>
</body>
</html>

Three parts do the work. The @keyframes blink rule says that halfway through the animation the text’s opacity is 0. The animation line runs that rule for one second per cycle and repeats it four times, so the effect lasts four seconds, safely under the five-second limit in WCAG 2.2.2. The step-end timing function makes the text switch instantly between visible and hidden, which looks like the classic hard blink and not a smooth fade. The media query at the bottom removes the animation for anyone who has asked for reduced motion.

What happened to the <blink> tag

The <blink> element was introduced in early versions of Netscape Navigator in the early-to-mid 1990s, before CSS was in wide use. MDN’s glossary says it was never properly specified and never gained significant cross-browser support, and that no current browser supports it. Wikipedia adds that Internet Explorer and WebKit-based browsers never supported it, which means Chrome and Safari never did either.

Firefox was the last browser to render it. Mozilla’s bug 857820, titled “Drop only blink effect from text-decoration: blink; and completely remove <blink> element,” tracked the change, and The Register reported in April 2013 that it would land in Firefox 23. Wikipedia dates the Firefox 23 release notes to 6 August 2013.

The standards side is just as clear. The HTML Standard lists blink among its entirely obsolete elements, which authors must not use, and points to CSS instead.

Does text-decoration: blink still work?

No. CSS has a blink value for text-decoration-line, and CSS 2.1 says conforming browsers may simply not blink the text. MDN’s compatibility data marks the value as deprecated and notes that it has no effect in Chrome, Firefox, Safari or Edge. A tutorial that tells you to write text-decoration: blink will leave you with static text.

Technique Result in current browsers
<blink> element Does not blink; Firefox removed it in version 23 (2013)
text-decoration: blink Parses, but has no effect
CSS @keyframes animation Works everywhere; the method to use
JavaScript timer Works; needed only for custom behavior

Method 1: make text blink with CSS animation

This is the method to use. It needs no JavaScript, works in every current browser, and keeps the blinking in your stylesheet where you can switch it off. MDN’s own example for the deprecated blink value uses the same idea: a keyframe that hides the text, run with steps() timing on an infinite loop.

Step 1: define the keyframes

@keyframes blink {
  50% { opacity: 0; }
}

You only need the 50% keyframe. The browser fills in 0% and 100% from the element’s normal style, so the text is visible, vanishes at the halfway point, then returns.

Step 2: attach the animation to a class

.blink {
  animation: blink 1s step-end 4;
}

The shorthand reads as name, duration, timing function, iteration count. Changing the last value from 4 to infinite makes it blink forever, which is where the accessibility problems start (see the accessibility section below).

Step 3: add the class to your HTML

<p>Sale ends <span class="blink">tonight at midnight</span>.</p>

Use a <span> for a few words inside a sentence, or put the class on a block element for a whole line.

Variations you can copy

Effect Change Notes
Hard on/off blink animation: blink 1s step-end 4 Classic look; the one used above
Soft fade pulse animation: blink 1.5s ease-in-out 3 Gentler on the eyes
Slower rhythm animation: blink 2s step-end 3 Fewer flashes per second
Keeps layout stable Animate opacity or visibility Avoid display: none, which makes the surrounding text jump

Animating opacity is the safer choice because the element keeps its space. Toggling display removes it from the layout and shifts neighboring content each time.

How it was tested

I ran the snippet in headless Chrome and sampled the computed opacity every 250 milliseconds. The text alternated between visible and hidden in two-sample steps for four cycles, then stayed visible, which matches 1s step-end 4. With the browser’s reduced-motion setting turned on, the animation name resolved to none and the yellow background applied. Chrome was the only browser tested, so check Firefox and Safari yourself before shipping.

Method 2: toggle a class with JavaScript

CSS handles nearly every case. JavaScript earns its place when the user needs control: a button that pauses the blinking, or logic that starts and stops it based on something happening on the page. The version below still lets CSS do the blinking and uses a few lines of script only to pause it, which is what WCAG 2.2.2 asks for.

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Blinking text with a pause button</title>
  <style>
    @keyframes blink { 50% { opacity: 0; } }

    .blink { animation: blink 1s step-end infinite; }
    .blink.is-paused { animation-play-state: paused; }

    @media (prefers-reduced-motion: reduce) {
      .blink { animation: none; background: #fff3b0; }
    }
  </style>
</head>
<body>
  <p>Live now: <span class="blink">Flash sale</span></p>
  <button type="button" id="toggle" aria-pressed="false">Pause blinking</button>

  <script>
    const text = document.querySelector('.blink');
    const button = document.getElementById('toggle');

    button.addEventListener('click', () => {
      const paused = text.classList.toggle('is-paused');
      button.setAttribute('aria-pressed', String(paused));
      button.textContent = paused ? 'Resume blinking' : 'Pause blinking';
    });
  </script>
</body>
</html>

In headless Chrome, clicking the button froze the computed opacity between two readings taken 1.3 seconds apart, flipped aria-pressed to true, and changed the label to “Resume blinking”. A second click restored the original state.

Why not use setInterval?

Many tutorials toggle visibility with setInterval. It works, but it has no advantage here. The timer keeps running while the tab is hidden, it ignores the visitor’s reduced-motion setting unless you add extra code, and it moves a visual effect into script where it is harder to maintain. Reach for a timer only when the blink must be driven by something CSS cannot see, such as live data.

Accessibility: the rules that apply to blinking text

Blinking text is one of the few visual effects that web accessibility standards address directly. MDN warns that it can be disorienting, can trigger seizures in the worst cases, and is a problem for people with conditions such as epilepsy or ADHD.

WCAG 2.2.2: Pause, Stop, Hide (Level A)

According to the W3C’s Understanding document, content that blinks, moves or scrolls, starts automatically, lasts more than five seconds and sits alongside other content must give users a way to pause, stop or hide it, unless the movement is essential. The goal is to avoid distraction for people with attention, cognitive or reading disabilities.

In practice: a blink limited to a few cycles, like the four-second example above, falls under the five-second line. A blink that runs forever needs a visible control, like the pause button in Method 2.

WCAG 2.3.1: Three Flashes or Below Threshold (Level A)

The W3C’s guidance on 2.3.1 says nothing may flash more than three times in any one-second period, unless the flashing stays below the defined thresholds. It exists to protect people with photosensitive seizure disorders. A one-second cycle that disappears and reappears once flashes about once per second, which is within the limit. Do not shorten the cycle to make the blink faster.

Respect prefers-reduced-motion

The prefers-reduced-motion media feature detects whether the visitor has asked their operating system to minimize motion. It takes no-preference or reduce, and MDN lists it as widely available across browsers since January 2020. MDN’s recommended pattern is to write the animation normally and override it inside a reduce query, which is exactly what the snippets in this guide do. Replace the blink with a static highlight so the emphasis survives.

Practical checklist

  • Limit the blink to a few cycles, or add a working pause control.
  • Keep it to one element on the page.
  • Never exceed three flashes in a second.
  • Provide the prefers-reduced-motion fallback.
  • Make sure the meaning does not depend on the blink: the text must make sense when it is static.

Better alternatives to blinking text

MDN advises against blinking text even though CSS can produce it. If your goal is attention, these options do the job without the drawbacks:

Goal Try this instead
Highlight a key phrase <mark> or a background color with enough contrast
Flag a new or live item A static badge such as “New” or “Live”
Draw the eye once A single short fade-in or a brief highlight that settles
Show an urgent state An icon plus text, not motion alone
Announce a change to screen-reader users An aria-live region, since blinking conveys nothing to them
.highlight {
  background: #fff3b0;
  padding: 0 .25em;
  border-radius: 2px;
}

When blinking is acceptable

Short, limited blinking can be reasonable: a text cursor in a demo editor, a brief pulse on a field that just updated, or a deliberate retro design. In each case keep it brief or controllable, keep it to one element, and keep the reduced-motion fallback. A blink that runs forever next to your main content is the pattern WCAG 2.2.2 is aimed at.

Troubleshooting: why your text isn’t blinking

Symptom Likely cause Fix
Nothing happens with <blink> The element is unsupported Use the CSS method
text-decoration: blink is static Browsers ignore the value Use @keyframes
Animation never starts Class name mismatch or missing @keyframes Check that the animation name matches the keyframes name exactly
It blinks only once Iteration count is 1 or the shorthand is out of order Put the count last: 1s step-end 4
Text fades instead of blinking ease timing used Switch to step-end
No blink on your own device Reduced motion is turned on in your OS Expected behavior; test with the setting off
Layout jumps You toggled display Animate opacity instead

Browser test checklist

  1. Open the page in Chrome, Firefox and Safari.
  2. Confirm the text blinks, then stops or can be paused.
  3. Turn on your system’s reduce-motion setting and reload: the blink should be gone and the highlight should show.
  4. Tab to the pause button and operate it with the keyboard.
  5. Check that the sentence still reads correctly when the text is hidden.

FAQ

What is the HTML code for blinking text?

There is no working HTML tag for it. Wrap the text in a <span class="blink"> and add a CSS @keyframes animation that toggles opacity, as shown in the copy-paste example near the top.

Does the <blink> tag still work?

No. Firefox removed it in version 23 in 2013, and Chrome, Safari and Internet Explorer never supported it. The HTML Standard lists it as obsolete.

Is blinking text bad for SEO?

I found no Google guidance that penalizes blinking text as such, so I won’t claim a ranking effect. The real risks are usability and accessibility, which can affect how people experience the page.

How do I make text blink without CSS?

You can toggle visibility with JavaScript, but CSS is simpler and easier to disable. Neither is recommended for long-running effects.

How do I stop blinking text for users who are sensitive to motion?

Add a @media (prefers-reduced-motion: reduce) rule that sets animation: none, and provide a pause button if the blink runs longer than five seconds.

Can I use <marquee> instead?

It is not a substitute for blinking, and the HTML Standard also lists it as non-conforming, recommending CSS animations instead.

Sources

John Div

John Div writes guides and explainers for Saasnm on SaaS tools, software platforms and web development. His articles cite their sources, and where a point is the author's own advice rather than a sourced fact, the article says so.

Leave a comment

Your email address will not be published. Required fields are marked *