How to Create Gradient Text in CSS With Background Clip

How to Apply Gradient to Text with CSS Background-Clip

Quick answer: To create gradient text in CSS, apply a gradient as the element’s background, clip that background to the text, and make the text fill transparent.

.gradient-text {
  background: linear-gradient(90deg, #7c3aed, #06b6d4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

This technique makes the background visible only through the shape of the text.

Basic CSS Gradient Text Example

Start with simple HTML:

<h2 class="gradient-text">Gradient Text</h2>

Then apply the CSS:

.gradient-text {
  background-image: linear-gradient(90deg, #ff4d8d 0%, #7c3aed 50%, #06b6d4 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
}

How the Technique Works

1. Create the gradient

linear-gradient() creates the color transition. You can change its angle, colors and stop positions.

2. Clip the background to the text

background-clip: text limits the painted background to the foreground text shape.

3. Make the normal text color transparent

color: transparent allows the clipped background to show through instead of a solid font color.

Add a Solid-Color Fallback

If you need a conservative fallback, declare a readable text color before the gradient-related declarations. Browsers that support the clipping technique can then apply the gradient.

.gradient-text {
  color: #6d28d9;
  background: linear-gradient(90deg, #6d28d9, #0891b2);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

Vertical and Diagonal Gradient Text

Change the gradient direction rather than the clipping technique:

/* Top to bottom */
background: linear-gradient(to bottom, #f97316, #ec4899);

/* Diagonal */
background: linear-gradient(135deg, #22c55e, #0ea5e9);

Gradient Text With Multiple Color Stops

background: linear-gradient(
  90deg,
  #ef4444 0%,
  #f59e0b 30%,
  #10b981 65%,
  #3b82f6 100%
);

Extra stops give you more control over where each color becomes dominant.

Why Is My Gradient Text Invisible?

  • The text was made transparent but the gradient declaration is missing or invalid.
  • The clipping declaration is not being applied.
  • Another CSS rule is overriding the background or text color.
  • The gradient colors have insufficient contrast against the surrounding page.
  • A browser-specific compatibility issue requires the prefixed declaration in your supported environment.

Gradient Text From a Figma Design

If you are translating an existing design rather than creating a gradient from scratch, first convert its color stops and direction. Our Figma Gradient to CSS guide explains that workflow.

Accessibility Considerations

Gradient text still needs to remain readable. Check contrast across the full gradient rather than testing only one color. Avoid using decorative gradient styling for long paragraphs, error messages or other text where clarity is more important than visual effect.

Frequently Asked Questions

Can I use a radial gradient on text?

Yes. Replace linear-gradient() with radial-gradient() while keeping the text-clipping technique.

Can I animate gradient text?

Yes. A common approach is to use an oversized background and animate background-position. Keep motion subtle and respect reduced-motion preferences where appropriate.

Should I use gradient text for body copy?

Usually not. It works best for short display text such as headings or labels where readability can be verified carefully.

Last reviewed: October 2026. Test the final result in the browsers your project supports.

Share this article:

On This Page

Subscribe to our newsletter

Read the latest articles from our experts

Related Posts

legal paper size measurement in inches and cm

US Letter Paper Size: 8.5 × 11 Inches in mm, cm and Pixels

Standard printer paper size in the United States is Letter size, which measures 8.5 × 11 inches. This guide explains normal printer paper dimensions, compares Letter with A4 and Legal paper, and helps you understand paper sizes for home printing, office documents, school assignments, and design projects.

How to Make Red Color (Complete Mixing Guide) Paint, Digital & Print Methods Explained

How to Make Red Color (Complete Mixing Guide): Paint, Digital & Print Methods Explained

Red is one of the most recognizable primary colors, but many people wonder whether it can be mixed or recreated using other colors. This guide explains how red works in traditional color theory, digital design, and printing while covering paint mixing, RGB, CMYK, and practical color applications for artists and designers.

CMYK to RGB Conversion Guide (Design & Print Colors) Understanding Digital and Print Color Models

CMYK to RGB Conversion Guide (Design & Print Colors): Understanding Digital and Print Color Models

Understanding the difference between CMYK and RGB is essential for designers, printers, photographers, and marketers. This guide explains how CMYK to RGB conversion works, compares popular color models, provides conversion formulas, and helps you choose the right format for both digital screens and professional printing projects.

PPC Budget Calculator Guide: How to Calculate Your Google Ads Budget & Maximize ROI

PPC Budget Calculator Guide: How to Calculate Your Google Ads Budget & Maximize ROI

Planning your advertising budget is essential for running profitable PPC campaigns. This guide explains how to calculate a PPC budget, estimate Google Ads costs, understand CPC and ROI, and use a budget calculator to make smarter advertising decisions while controlling costs and improving campaign performance.

Best Font Pairings for Websites and Branding 2026 Guide

Best Font Pairings for Websites and Branding 2026 Guide

Discover the best font pairings for websites branding and modern design in this complete 2026 guide Learn how to combine typography styles improve readability create professional visual identity and choose good font pairs for blogs businesses ecommerce and creative projects using practical design strategies and free online tools effectively

HEX to RGB Converter Formula Examples and Tool Guide

HEX to RGB Converter Formula Examples and Tool Guide

Learn hex to rgb conversion with simple formulas and real examples This guide explains how hexadecimal to rgb color works, how to convert manually, and how to use accurate tools to get instant results for design, coding, and digital projects with complete ease and precision

How to Make Brown Color Complete Paint Mixing Guide for Beginners

How to Make Brown Paint: Color Mixing Recipes and Adjustments

Learn how to make brown color using simple paint mixing techniques This complete guide explains what colors make brown, how to adjust shades, and how to create perfect tones for painting, design, and art projects using easy methods suitable for beginners and professionals alike with accurate and practical results

How to Crop an Image Online Free and Easy Guide

How to Crop an Image Online Free and Easy Guide

Learn how to crop image online using simple and free tools This guide explains how to crop jpg image and png image accurately improve image quality and use crop image tool effectively for social media design and web use with easy steps for all users

CSS Beautify Tool Guide Format CSS Online Easily

CSS Beautify Tool Guide Format CSS Online Easily

Learn how to use a css beautify tool to format css online easily This guide explains css beautifier benefits, code formatting techniques, and how to improve readability and maintain clean structured css using simple methods and free tools for developers and beginners

Social Media Video Sizes Guide All Platforms 2026

Social Media Video Sizes Guide All Platforms 2026

Learn social media video sizes for all major platforms in 2026 This guide explains video dimensions formats and aspect ratios to help you create perfect videos for Instagram YouTube TikTok and more ensuring high quality uploads better engagement and professional results across all devices and platforms easily

How to Create Favicon for Website Step by Step Guide

How to Create Favicon for Website Step by Step Guide

Learn how to create favicon for website using simple step by step methods This guide explains how to make icon for website, choose the right size and format, and use free tools to generate professional favicons for branding and better user experience across all devices and browsers easily

Animated Gradient Background Generator Create Stunning CSS Backgrounds Easily

Animated CSS Gradient Background: Code, Examples and Generator Guide

Want to create smooth, modern website backgrounds without writing complex CSS from scratch? This guide explains how an animated gradient background generator works, why designers use it, and how to create eye-catching moving gradients for websites, landing pages, and hero sections. You will also see practical tips and common mistakes.

Font Size Converter Guide – Formulas, Manual Calculations & Unit Conversions

Font Size Conversion: px, rem, em, pt and Percent

This font size converter guide explains how to manually convert font sizes between px, pt, em, rem, percent, vw, vh, cm, mm, inches, and picas. Learn formulas, calculation methods, and practical examples for accurate typography conversions used in responsive web design, print layouts, and modern CSS development workflows across devices and screen sizes.

Optimal Font Size for Website Readability – Complete Typography Guide

Website Font Size Guide: Readable Body Text and Responsive Typography

This font size converter guide explains the optimal font size for website readability. Learn recommended typography sizes, accessibility guidelines, and responsive font practices for web design. Discover how to choose body text, headings, and mobile font sizes while converting units like px, em, and rem to maintain consistent, readable typography across devices.

CSS Gradients in Web Design – Performance, Best Practices & Browser Support

How to Convert a Figma Gradient to CSS

This CSS gradient generator guide explains how to convert Figma gradients into CSS code accurately. Learn how to extract color stops, angles, and gradient types from Figma, convert them into linear or radial CSS gradients, and optimize them for responsive web design, browser compatibility, and performance using efficient development techniques and tools.

CSS Gradients in Web Design – Performance, Best Practices & Browser Support

CSS Gradients in Web Design – Performance, Best Practices & Browser Support

This CSS gradient generator guide explains performance impacts, best practices, and browser support for modern CSS gradients. Learn how to optimize gradient rendering, improve website speed, ensure cross-browser compatibility, and create visually appealing backgrounds using efficient CSS techniques for responsive and high-performance web design across all devices and screen sizes globally.

Tools & Resources

Explore our collection of professional tools designed to streamline your workflow

Report a Bug