Text Inside Image and Gradient Color


Create display type filled with a photograph or CSS gradient using the -webkit-background-clip: text technique (with standard background-clip: text). This generator builds the CSS text inside image and gradient color styles for you: set your wording, pick an image URL or gradient, adjust size and position, then copy the markup.

You can also animate the fill so the image or gradient appears to move up, down, left, or right inside the letters. Use the live preview below, then paste the HTML and CSS into hero banners, logos, or social graphics. See the text mask demo page for a minimal example.

CSS text inside image generator showing photo-filled headline text with background-clip and gradient color options
Fill headline text with a background image or gradient, tune position, and export CSS with background-clip text.

Text inside image generator

Preview text filled with a background image or gradient, tune typography and position, optionally animate the fill, then copy the HTML and CSS output.

Text Mask
Set Font Size
Type
BG Image:
ร—
Background Animation
Stroke:

Generated code

HTML
<div class="text-mask">Text Mask</div>
CSS
.text-mask {
	font-size: 100px;
	font-family: Impact, Charcoal, sans-serif;
	background-image: url("/images/bg/mask-image8.jpg");
	background-position: 0px 0px;
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: #0000;
}

What is background-clip text?

Background clipping lets a background-image or gradient show only where text is painted. You make the glyph fill transparent with color: transparent or -webkit-text-fill-color: transparent, then set background-clip: text (and the WebKit-prefixed variant) so the background is masked to letter shapes. The result looks like a photo or gradient living inside the type itself.

This pattern is popular for hero headlines, event posters, and brand lockups because it keeps markup simple: one heading element and a CSS class instead of rasterizing text in an image editor.

  • Works on any HTML text node that accepts regular font styling.
  • Supports still photos, repeating textures, and CSS gradients.
  • Pairs well with large display fonts such as Impact or Arial Black.

Open the generator when you are ready to pick image or gradient fill, preview the mask, and copy code.

CSS syntax

The core properties for image or gradient text fills are listed below. Browsers still expect the WebKit-prefixed clip property on many sites, so include both declarations in production CSS.

Property Role
background-image or background Photo URL, texture, or gradient that will show through the letters.
background-size / background-position Controls how much of the image is visible inside each glyph and where it is anchored.
-webkit-background-clip: text Legacy WebKit clip that masks the background to text (still widely used).
background-clip: text Standard clip keyword with the same masking behavior.
-webkit-text-fill-color: transparent Makes the solid text color invisible so the background shows through.
color: transparent Fallback transparent fill where the WebKit text fill property is not applied.

How to use this tool

Follow these steps in the generator to place an image in text or switch to a gradient fill, then export copy-ready code.

  1. Type your headline in the preview text field and pick a font size and family.
  2. Choose Image fill and paste a photo URL, or choose Gradient fill and set colors, type, and angle.
  3. Drag background position sliders until the crop inside the letters looks right.
  4. Optional: turn on background animation, set speed in seconds, and pick a direction (up, down, left, right).
  5. Copy the HTML and CSS blocks into your stylesheet or component.
  6. Test on mobile widths; very long words may need a smaller font size or shorter line.

Need a stripped-down sample? Try the standalone text mask demo.

Features

The generator on this page focuses on background-clip text workflows: live preview, fill modes, motion, and code export.

  • Image fill - use any hosted photo URL as the text texture.
  • Gradient fill - linear, radial, repeating linear, and repeating radial gradients.
  • Typography controls - font size, family presets, and preview background color.
  • Background position - nudge the crop inside letters on both axes.
  • Animated fills - move the background up, down, left, or right on a timed loop.
  • Copy-ready output - separate HTML and CSS blocks with the .css-text-mask class pattern.

Gradient text fill

Gradients use the same clipping rules as photos. Set background-image to a linear-gradient() or radial-gradient(), then clip it to the text. Repeating variants tile color bands inside each letter for stripe effects.

CSS
.css-text-mask {
	font-size: 72px;
	font-family: Impact, Charcoal, sans-serif;
	background-image: linear-gradient(120deg, #f97316, #ec4899, #8b5cf6);
	background-size: cover;
	background-position: center;
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
}

Pick gradient type and angle in the generator to update this pattern automatically.

Image text fill

To place an image in text, point background-image at your asset, size it with background-size, and align with background-position. Transparent text color lets the photo show only inside glyphs.

CSS
.css-text-mask {
	font-size: 100px;
	font-family: Impact, Charcoal, sans-serif;
	background-image: url('/mask-image.png');
	background-position: 0 0;
	background-size: cover;
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
}

Use high-contrast photos with clear subjects; busy backgrounds can make letter shapes harder to read at small sizes.

Animate the fill

Motion inside clipped text comes from animating background-position (or the shorthand background) over time. The generator can add a keyframe loop that shifts the image or gradient up, down, left, or right based on the direction and speed you choose.

CSS
@keyframes text-mask-down {
	from { background-position: 50% 0%; }
	to { background-position: 50% 100%; }
}

.css-text-mask {
	animation: text-mask-down 10s linear infinite;
}

Shorter durations feel energetic; longer loops (10 seconds or more) suit subtle hero motion. Prefer animating one headline at a time on mobile to limit paint work.

Example CSS

Combine the HTML heading with the CSS class below for a photo-filled display line. Replace the image path and font settings to match your brand.

HTML
<h1 class="css-text-mask">Summer Sale</h1>
CSS
.css-text-mask {
	display: inline-block;
	font-size: 100px;
	font-family: Impact, Charcoal, sans-serif;
	background-image: url('/images/bg/mask-image13.jpg');
	background-position: 0 0;
	background-size: cover;
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
}

Browser support

background-clip: text works in current Chrome, Edge, Safari, and Firefox releases when you include the WebKit clip and transparent text fill properties. Very old browsers without clipping may show solid text color instead; keep a readable fallback color in your base stylesheet if you support legacy clients.

  • Chrome and Edge: supported with prefixed and standard clip.
  • Safari and iOS Safari: use -webkit-background-clip and -webkit-text-fill-color.
  • Firefox: supports standard background-clip: text in modern versions.

Frequently asked questions

Common questions about placing images or gradients inside text with CSS clipping and animation.

What does background-clip text do?

It limits the element background painting area to the shape of the text glyphs, so a photo or gradient appears only inside letters instead of behind the whole box.

How do I put an image inside text with CSS?

Set background-image to your photo, make the text color transparent, and apply -webkit-background-clip: text plus background-clip: text. Adjust background-size and background-position until the crop looks right.

Can I use a gradient instead of a photo?

Yes. Use linear-gradient(), radial-gradient(), or repeating gradient functions as the background-image value, then clip it to the text the same way as an image URL.

Why do I need -webkit-background-clip and transparent text color?

WebKit-based browsers still expect the prefixed clip property, and transparent fill prevents the solid text color from covering the background. Including both clip declarations and transparent fill gives the widest support.

How do I animate the image or gradient inside text?

Animate background-position with CSS keyframes. Change start and end positions on the axis you want (vertical for up or down, horizontal for left or right) and set animation-duration to control speed.

Does clipped text work on mobile browsers?

Yes. Modern mobile Chrome, Safari, and Firefox support background-clip text when you include the WebKit properties. Test performance if you animate large headline type on low-end devices.

These generators pair well when you are styling display type, color, and depth around clipped headlines.