CSS Text Effects
Pure CSS can produce stunning visual text effects — no images, no JavaScript, no design software required. In this chapter you'll build gradient text, neon glows, animated shimmers, typewriters, 3D layers, glitch effects and more from scratch.
background-clip: texttext-shadow-webkit-text-stroke@keyframesText Effects — Live Gallery
Every card below is a live CSS effect — no images. Hover over them to see interactive states where applicable.
Gradient Text
Neon Glow
Outlined Text
3D & Shadow Effects
Animated Effects
Glitch Effect
1. Gradient Text
Gradient text is achieved by clipping a gradient background to the text shape. Three CSS declarations work together — without all three the effect breaks silently.
linear-gradient, radial-gradient or
conic-gradient.
-webkit-background-clip: text and the standard version for full
browser support.
-webkit-text-fill-color: transparent and color: transparent./* ── Static gradient text ── */
.gradient-text {
background: linear-gradient(90deg, #264de4, #a855f7);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
color: transparent;
}
/* ── Animated shimmer ── */
@keyframes shimmer {
0% { background-position: 0% 50%; }
100% { background-position: 200% 50%; }
}
.shimmer-text {
background: linear-gradient(90deg,
#264de4 0%, #a855f7 25%, #fff 50%,
#a855f7 75%, #264de4 100%);
background-size: 200% auto;
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
animation: shimmer 3s linear infinite;
}
2. Neon Glow Effect
Neon glow is built with text-shadow — stacking
multiple shadows at zero offset with increasing blur radii. The colour of the text itself sets the core
brightness; the shadows create the bloom effect around it.
/* Neon blue — needs a dark background to look authentic */
.neon-blue {
color: #44aaff;
text-shadow:
0 0 7px #44aaff, /* tight core glow */
0 0 14px #44aaff, /* mid bloom */
0 0 28px #44aaff, /* outer bloom */
0 0 56px #0066ff, /* wider deeper hue */
0 0 100px #0066ff; /* atmospheric spread */
}
.neon-pink {
color: #ff44aa;
text-shadow:
0 0 7px #ff44aa,
0 0 14px #ff44aa,
0 0 28px #ff44aa,
0 0 56px #ff00aa,
0 0 100px #ff00aa;
}
/* Pulsing neon animation */
@keyframes neonPulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.7; }
}
.neon-pulse {
color: #44aaff;
text-shadow: 0 0 7px #44aaff, 0 0 28px #44aaff, 0 0 56px #06f;
animation: neonPulse 2s ease-in-out infinite;
}
3. Outlined Text (Text Stroke)
The -webkit-text-stroke property draws a stroke
around text characters. It is widely supported but still requires the -webkit- prefix. Set color: transparent
(or -webkit-text-fill-color: transparent) to show only the outline.
/* Outline-only text */
.outlined {
color: transparent;
-webkit-text-stroke: 2px #264de4; /* width color */
}
/* Stroke with fill — stroke draws INSIDE the text */
.stroke-fill {
color: #fff;
-webkit-text-stroke: 3px #264de4;
}
/* Hover — outline fills with gradient */
.outline-hover {
-webkit-text-stroke: 2px #264de4;
-webkit-text-fill-color:transparent;
transition: -webkit-text-fill-color 0.3s;
}
.outline-hover:hover {
-webkit-text-fill-color: #264de4;
}
-webkit-text-stroke draws the stroke centred on the character's
outline — half inside, half outside. This means thick strokes will visually narrow the letter. For thick
strokes, increase font-weight to compensate.
4. 3D Text Effect
Stacking multiple text-shadow layers at increasing
offsets — each one slightly more transparent — creates a convincing 3D depth illusion entirely in CSS.
/* ── Classic 3D layered shadow ── */
.text-3d {
color: #fff;
text-shadow:
1px 1px 0 #264de4, /* layer 1 */
2px 2px 0 rgba(38,77,228,.8), /* layer 2 */
3px 3px 0 rgba(38,77,228,.6), /* layer 3 */
4px 4px 0 rgba(38,77,228,.4), /* layer 4 */
5px 5px 0 rgba(38,77,228,.2), /* layer 5 */
5px 5px 12px rgba(0,0,0,.5); /* ambient shadow */
}
/* ── Retro hard shadow (two colours) ── */
.text-retro {
color: #fff;
text-shadow:
4px 4px 0 #ef4444,
8px 8px 0 #f97316;
}
/* ── Long shadow (many fine layers) ── */
.text-long-shadow {
color: #fff;
text-shadow:
1px 1px 0 rgba(38,77,228,.5),
2px 2px 0 rgba(38,77,228,.45),
3px 3px 0 rgba(38,77,228,.4),
4px 4px 0 rgba(38,77,228,.35),
5px 5px 0 rgba(38,77,228,.3),
6px 6px 0 rgba(38,77,228,.25),
7px 7px 0 rgba(38,77,228,.2),
8px 8px 0 rgba(38,77,228,.15);
}
5. Typewriter Animation
The typewriter effect uses @keyframes to animate
the element's width from 0 to its
natural width, combined with overflow: hidden and white-space: nowrap to reveal text character by character. The cursor is a
right border that blinks with a separate animation.
/* Typing animation */
@keyframes typing {
from { width: 0; }
to { width: 100%; }
}
/* Cursor blink */
@keyframes blink {
50% { border-color: transparent; }
}
.typewriter {
display: inline-block;
overflow: hidden;
white-space: nowrap;
width: 100%; /* end state */
border-right: 3px solid #264de4; /* cursor */
animation:
typing 3s steps(30, end) forwards,
blink .75s step-end infinite;
}
/* HTML */
<p class="typewriter">Hello, I build amazing websites!</p>
/*
KEY POINTS:
- steps(30, end) — number must match character count
- forwards — keeps the end state (text fully visible)
- white-space: nowrap — prevents text wrapping
- border-right simulates the cursor
*/
steps() should roughly equal the number of characters
in your text. For "Hello, I build amazing websites!" (32 characters), use steps(32, end). Too few steps and the animation looks jerky; too many and it
stutters between characters.
6. Highlighted / Marker Text
The marker highlight effect uses a linear-gradient
background that is transparent in the top half and coloured in the bottom half. This mimics a highlighter
pen without touching the actual text colour.
/* Yellow marker highlight */
.mark {
background: linear-gradient(
transparent 55%, /* top half: transparent */
rgba(255, 207, 0, 0.5) 55% /* bottom half: highlight */
);
display: inline; /* must be inline to follow text flow */
}
/* Blue brand highlight */
.mark-blue {
background: linear-gradient(
transparent 55%,
rgba(38, 77, 228, 0.25) 55%
);
display: inline;
}
/* Animated highlight reveal */
@keyframes highlightIn {
from { background-size: 0% 100%; }
to { background-size: 100% 100%; }
}
.mark-animated {
background: linear-gradient(transparent 55%, rgba(255,207,0,.5) 55%);
background-repeat: no-repeat;
background-size: 0% 100%;
animation: highlightIn 0.5s ease forwards;
display: inline;
}
7. Glitch Effect
The glitch effect creates two coloured pseudo-element copies of the text (::before and ::after) that animate with
clip-path to show random slices at random offsets, mimicking a digital
signal glitch.
/* HTML — data-text must match the text content */
<h1 class="glitch" data-text="GLITCH">GLITCH</h1>
@keyframes glitch-top {
0%,100%{ clip-path:inset(0 0 80% 0); transform:translate(-4px, 0); }
25%{ clip-path:inset(20% 0 40% 0); transform:translate(4px, 0); }
50%{ clip-path:inset(50% 0 10% 0); transform:translate(-2px, 0); }
75%{ clip-path:inset(70% 0 5% 0); transform:translate( 2px, 0); }
}
@keyframes glitch-bot {
0%,100%{ clip-path:inset(80% 0 0 0); transform:translate(4px, 0); }
25%{ clip-path:inset(40% 0 30% 0); transform:translate(-4px, 0); }
50%{ clip-path:inset(10% 0 60% 0); transform:translate( 2px, 0); }
75%{ clip-path:inset(30% 0 50% 0); transform:translate(-2px, 0); }
}
.glitch { position: relative; color: #f0f0e8; }
.glitch::before,
.glitch::after {
content: attr(data-text); /* reads text from HTML attribute */
position: absolute;
top: 0; left: 0;
}
.glitch::before{
color: #ef4444;
animation: glitch-top 2s infinite linear;
}
.glitch::after{
color: #4a8af4;
animation: glitch-bot 2s infinite linear;
}
8. Blur Reveal & More Effects
A few more useful effects that are each just one or two CSS properties:
/* ── Blur reveal on hover ── */
.blur-text {
filter: blur(6px);
transition: filter 0.4s ease;
cursor: pointer;
}
.blur-text:hover { filter: blur(0); }
/* ── Rainbow animated ── */
@keyframes rainbow {
0% { filter: hue-rotate(0deg); }
100% { filter: hue-rotate(360deg); }
}
.rainbow-text {
background: linear-gradient(90deg,#ef4444,#f97316,#eab308,#22c55e,#06b6d4,#264de4,#a855f7);
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
animation: rainbow 4s linear infinite;
}
/* ── Fill reveal on load ── */
@keyframes fillIn {
from{ -webkit-text-fill-color: transparent; }
to { -webkit-text-fill-color: #264de4; }
}
.fill-reveal {
-webkit-text-stroke: 2px #264de4;
-webkit-text-fill-color:transparent;
animation: fillIn 1.5s ease 0.5s forwards;
}
/* ── Emboss (dark theme) ── */
.emboss {
color: rgba(255,255,255,.1);
text-shadow: 0 1px 0 rgba(255,255,255,.2),
0 -1px 0 rgba(0,0,0,.6);
}
Try It Yourself
This editor combines multiple effects on a hero card. Try swapping the gradient colours, changing the neon shadow colour, or adjusting the typewriter steps count.
Quick Check — Chapter 9
1.
background: linear-gradient(…) — sets the
gradient that will be visible through the text.2.
-webkit-background-clip: text; background-clip: text; — clips the
background to the text shape only. Both the prefixed and standard versions are needed for full
cross-browser support.3.
-webkit-text-fill-color: transparent; color: transparent; — makes the
text fill transparent so the gradient background shows through the letter shapes.
text-shadow values at zero
offset (same x,y position as the text) with progressively increasing blur radii — for
example: 0 0 7px #44aaff, 0 0 14px #44aaff, 0 0 28px #44aaff, 0 0 56px #06f.The tight-radius shadows form the core glow; the wide-radius shadows create the atmospheric bloom around the letters. The text's own
color provides the bright centre
point.It requires a dark background because glow effects only look like glowing light against darkness — on a white background, the effect is invisible since bright colours on white have no contrast.
1.
overflow: hidden — hides the text beyond the
element's current width.2.
white-space: nowrap — prevents the text from
wrapping to a new line.3. A
@keyframes typing animation that animates
width from 0 to 100% — this reveals the text gradually as the element grows.4. The
steps(N, end) timing function makes the
animation jump in discrete steps rather than smoothly — each step reveals roughly one character. N
should match the character count.5.
border-right: 3px solid #color + a @keyframes blink animation toggles the border colour to simulate the
cursor blinking.
::before and ::after
pseudo-elements. Each uses content: attr(data-text) to read the text
from an HTML attribute — this is why the HTML element needs both the visible text and a matching data-text attribute.Each pseudo-element is given a different colour (red and blue) and animated with a
@keyframes animation that:— Changes
clip-path: inset() to show random horizontal slices of the
copy at random times.— Applies a small horizontal
transform: translate() offset to shift
the slice sideways.The two coloured slices appearing at slightly different positions over the original text create the chromatic-aberration glitch illusion.
background: linear-gradient(transparent 55%, rgba(255,207,0,0.5) 55%);The gradient goes from transparent (0% to 55% = above the baseline) to the highlight colour (55% to 100% = below the baseline, where the bottom of letters sit). This leaves the text colour completely unchanged and only colours the space under the letters — exactly like a real highlighter pen.
The element must be
display: inline (not block) so the background follows the text flow across multiple lines
rather than filling a rectangular box.
steps() timing function do in
the typewriter animation?- Gradient text requires three properties:
background: gradient+background-clip: text+color: transparent. Missing any one breaks it silently. - Animated shimmer extends gradient text by animating
background-positionwith a largebackground-size. - Neon glow uses multiple
text-shadowlayers at zero offset with increasing blur radii. Needs a dark background to be visible. - Outlined text uses
-webkit-text-stroke: 2px colorwithcolor: transparentto show only the stroke. - 3D text stacks multiple
text-shadowvalues at incremental offsets with decreasing opacity. - Typewriter animation:
overflow: hidden+white-space: nowrap+width: 0 → 100%withsteps(N, end)+ blinkingborder-rightcursor. - Marker/highlight: a gradient background that is transparent in the top 55% and coloured
in the bottom 45% — on an
inlineelement. - Glitch effect:
::before/::afterpseudo-elements usingcontent: attr(data-text)+ animatedclip-pathandtransform. - Blur reveal:
filter: blur(6px)→filter: blur(0)on hover, withtransitionfor smooth reveal.
Rate Us on Google
Join Our Learning Community
Connect with thousands of learners, get daily tips, ask questions and stay updated with new tutorials.