Tutorials CSS Text Effects
Ch 9 / 60
Chapter 9 Intermediate 6 min read CSS

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.

What you'll learn
Gradient text with background-clip: text
Neon glow and multi-layer text-shadow
Outlined text with -webkit-text-stroke
Typewriter animation with @keyframes
3D text, glitch effect, shimmer, rainbow, blur reveal
Highlighted/marker text, emboss and letterpress

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.

background: linear-gradient(…)
Sets the gradient that will show through the text. Use linear-gradient, radial-gradient or conic-gradient.
background-clip: text
Clips the background to the text shape only. Always include both the prefixed -webkit-background-clip: text and the standard version for full browser support.
color: transparent
Makes the text fill transparent so the gradient background shows through. Use both -webkit-text-fill-color: transparent and color: transparent.
CSS — Gradient text
/* ── 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;
}
Accessibility note
Always ensure sufficient contrast between the gradient and the background. Pure gradient text can fail WCAG contrast requirements if the colours are too light against a white background. Test your gradient text with a contrast checker.

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.

CSS — Neon glow recipe
/* 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.

CSS — Text stroke
/* 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;
}
Stroke draws inward
-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.

CSS — 3D and retro shadow text
/* ── 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.

CSS + HTML — Typewriter effect
/* 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 count trick
The number inside 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.

This is normal text but this phrase has a yellow highlight marker effect applied with pure CSS, and this one uses a blue tint instead.
CSS — Marker/highlight text
/* 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.

CSS + HTML — Glitch effect
/* 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:

CSS — Blur reveal, rainbow, fill reveal, emboss
/* ── 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);
}
Free Resource
CSS3 Cheat Sheet — All Properties & Selectors
One printable page covering every CSS3 property, selector type, unit, layout system and all text effect techniques.
Download PDF

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.

Live Editor
✎ Editor
👁 Preview
Featured Course — Enroll Now
Modern Web Development With AI
Master HTML, CSS, JavaScript, React and Node.js — all in one industry-ready curriculum. Build real projects with AI-powered tools and get placement support.
120+
Chapters
40 hrs
Content
10 Real
Projects
4.9 ⭐
Rating
HTML5 CSS3 JavaScript React.js Node.js Tailwind CSS AI Tools

Quick Check — Chapter 9

Questions & Answers
All three of the following must be present — omitting any one of them causes the effect to break silently:

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.
Neon glow is created by stacking multiple 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.
The typewriter effect combines several CSS properties:

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.
The glitch effect creates two invisible copies of the text using ::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.
The marker highlight uses a two-stop linear gradient as the element's background, where the top portion is transparent and the bottom is the highlight colour:

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.
Multiple Choice Questions
Question 1 of 5
Which property clips a gradient background to the text shape for gradient text?
Question 2 of 5
What does the steps() timing function do in the typewriter animation?
Question 3 of 5
Which CSS property draws a visible stroke around text characters?
Question 4 of 5
What does the glitch effect use to display copies of the text via pseudo-elements?
Question 5 of 5
Which CSS property creates the blur-to-clear reveal effect on hover?
Chapter Summary
  • 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-position with a large background-size.
  • Neon glow uses multiple text-shadow layers at zero offset with increasing blur radii. Needs a dark background to be visible.
  • Outlined text uses -webkit-text-stroke: 2px color with color: transparent to show only the stroke.
  • 3D text stacks multiple text-shadow values at incremental offsets with decreasing opacity.
  • Typewriter animation: overflow: hidden + white-space: nowrap + width: 0 → 100% with steps(N, end) + blinking border-right cursor.
  • Marker/highlight: a gradient background that is transparent in the top 55% and coloured in the bottom 45% — on an inline element.
  • Glitch effect: ::before/::after pseudo-elements using content: attr(data-text) + animated clip-path and transform.
  • Blur reveal: filter: blur(6px) → filter: blur(0) on hover, with transition for smooth reveal.
~6 min read
Intermediate
Chapter 9 of 60

Rate Us on Google

4.8 / 5
Enjoying this tutorial?
Your 5-star review helps other learners discover our free tutorials and encourages us to keep creating quality content.
80+ reviews
Write a Google Review
Join WhatsApp Channel