The neon glow inspired by shop windows not only attracts attention, but also adds a futuristic touch to website designs. With CSS, we can recreate this exciting effect without even resorting to complex graphic tools.
How to create text glow using CSS
HTML structure
Let's start by creating a simple HTML structure:
<div class="container">
<h1 class="neon-text">SIGNBOARD</h1>
<h2 class="neon-text">WHICH GLOWS</h2>
</div>
CSS for glowing effect
The main tool for creating a neon glow is the property text-shadow
, which allows you to add multiple shadows to text. Below is an example of CSS code:
.neon-text { color: #fff; text-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 5px #fff, 0 0 11px #0fa, 0 0 20px #0fa, 0 0 30px #0fa, 0 0 55px #0fa, 0 0 80px #0fa; }
Animations to add dynamism
Pulsating Light
The pulsating effect is created by changing the blur radius:
@keyframes pulsate { 0%, 100% { text-shadow: /* minimum glow */; } 50% { text-shadow: /* maximum glow */; } } .neon-text { animation: pulsate 2.5s infinite alternate; }
Flickering
Neon is often associated with flickering. This can be easily simulated using CSS animations and keyframes
.
@keyframes flicker { 0%, 18%, 22%, 25%, 53%, 57%, 100% { text-shadow: /* full glow */; } 20%, 24%, 55% { text-shadow: none; } } .neon-text { animation: flicker 1.5s infinite alternate; }
Creating neon effects in web design with CSS allows you to not only improve the visual perception of the site, but also to bring an element of surprise and admiration, making the interface more memorable. These techniques are available to any developer who wants to add a little light and color to their projects.