HTML and CSS

Neon text with a flickering effect

WORRY SERVES
NO USEFUL PURPOSE

How can you create a neon text with a flickering effect?

Here’s a simple way to create a neon text effect with a flickering animation using CSS:

HTML
<div class="demo-bg">
<div class="demo-text">
WORRY SERVES NO USEFUL PURPOSE
</div>
</div>

The key part is the CSS property @keyframes flicker, which alternates the text shadow to simulate a flicker:

CSS
@import url('https://fonts.googleapis.com/css2?family=Tilt+Neon&display=swap');

.demo-bg {
  padding: 4em 2em;
  background-color: #000;
  background-image: url("bg.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  text-align: center;
}

.demo-text {
  color: #fff;
  font-family: 'Tilt Neon', cursive;
  font-size: 2.4em;
  line-height: 1.2em;
  text-shadow:
  0 0 10px #fff,
  0 0 20px #fff,
  0 0 30px #fff,
  0 0 40px #0fa,
  0 0 80px #0fa;
} 
  
@keyframes flicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.demo-text {
  animation: flicker 3s infinite alternate;
}