CSS Text Stroke Generator


CSS text stroke is a styling technique that adds a border or outline around individual characters. It suits headlines, titles, and other prominent display lines where you want strong contrast or a poster-style look.

The stroke is controlled by width and color (commonly via -webkit-text-stroke and related longhand properties). Use the live generator below to tune stroke width, fill color, optional shadows, and gradient or image backgrounds, then copy the exported HTML and CSS.

Demo CSS text stroke
CSS text stroke generator showing outlined headline text with stroke width, fill color, and gradient options
Live preview of outlined display type with stroke width, fill, and optional gradient or image backgrounds.

Online CSS text stroke generator

Beautify display type with an outline that makes letters pop. Pick stroke and fill colors, optional Google Fonts, text-shadow, and background gradients or images, then generate copy-ready markup.

Customize font weight, style, size, stroke width, and letter spacing in the live preview before you copy the output.

How to use this generator

  1. Enter your headline in the preview text field and choose a font family or load a Google Font.
  2. Set stroke color, fill color, and preview background (white, black, or transparent checkerboard).
  3. Open the Size tab to adjust font size, stroke width, and letter spacing.
  4. Optional: enable Text Shadow and tune offset, blur, opacity, and shadow color.
  5. Optional: enable Background for gradient or image fills on the text fill or stroke border.
  6. Click Generate code, then copy the HTML and CSS blocks into your project.
Text Stroke
Size

Generated code

HTML
<div class="text-stroke">Text Stroke</div>
CSS
.text-stroke {
	-webkit-text-stroke: 1.5px #0066ff;
	-webkit-text-fill-color: #fff;
	font-size: 75px;
	font-family: Arial Black, Gadget, sans-serif;
}

What is CSS text stroke?

Text stroke paints an outline along the edges of each glyph. Unlike a box border around a text container, the stroke follows letter shapes, which makes it useful for logos, hero headings, and short display lines.

In CSS you typically set stroke width and stroke color with -webkit-text-stroke-width and -webkit-text-stroke-color, or the -webkit-text-stroke shorthand. Pair those with a solid color or -webkit-text-fill-color for the inner fill.

  • Improves readability when type sits on busy photography or gradients.
  • Creates bold poster lettering without extra SVG markup.
  • Combines with background-clip: text for gradient or image strokes and fills.

Open the online generator when you want sliders for width, colors, shadows, and backgrounds with instant code export.

How to use -webkit-text-stroke

Set stroke width and color on the text element, then choose a fill color so the inside of each letter stays visible. The shorthand combines width and color in one declaration.

Property Role
-webkit-text-stroke-width Outline thickness in any valid length unit (px, em, rem, and so on).
-webkit-text-stroke-color Stroke color using any CSS color format (name, hex, rgb, rgba, and so on).
-webkit-text-stroke Shorthand for width and color together (for example, 2px #ff0000).
color / -webkit-text-fill-color Inner glyph fill; use transparent fill when a clipped background should show through.

To use the -webkit-text-stroke property in CSS, you can follow these steps:

Syntax

CSS
element {
	-webkit-text-stroke-width: <width>
	-webkit-text-stroke-color: <color>
}
  • width: Specifies the width of the stroke. This can be given in any valid CSS unit such as px, em, etc.
  • color: Specifies the color of the stroke (border / outline). This can be any valid CSS color value (name, hex, rgba, rgb, etc.).

You can also use shorthand to combine these two properties. -webkit-text-stroke

Shorthand Property:

CSS
element {
	-webkit-text-stroke: 2px #65ff9f;
}

Basic text stroke example

A simple headline stroke uses a medium display size, a dark outline, and a contrasting fill color. A common starting point is roughly 1.5px stroke width with a green fill and black stroke on an h1 element, using a heavy font such as Impact or Arial Black.

Preview

CSS text stroke
HTML
<h1 class="text-stoke">CSS text stroke</h1>
CSS
.text-stoke {
	font-size: 75px;
	-webkit-text-stroke-width: 1.5px;
	-webkit-text-stroke-color: #000000;
	-webkit-text-fill-color: #65ff9f;
	font-family: Arial,Helvetica,sans-serif;
}

Gradient or image on the stroke outline

To show a gradient or photograph in the stroke itself, set the stroke color to transparent so the outline area can reveal a background. Apply a linear-gradient() or background-image, then clip it to text with -webkit-background-clip: text and background-clip: text.

How To Add Gradient or Mask With An Image To Text Stroke (Border)

To add a gradient or image to a text stroke (Outline), first set the stroke color to transparent. Then, apply two CSS properties: background-clip: text; and background: linear-gradient(0deg, #00e7ff, #ff00d4);.

Preview gradient stoke

Gradient Stroke

Preview stoke mask with an image

Image Stroke

Here's how you can structure your CSS

HTML
<h1 class="gradient-text-stoke">Gradient Stroke</h1>
CSS
.gradient-text-stoke {
	font-size: 75px;
	-webkit-text-stroke-width: 9px;
	-webkit-text-stroke-color: transparent;
	-webkit-text-fill-color: #ffffff;
	font-family: cursive;
	/* gradient */
	background: linear-gradient(0deg, #00e7ff, #ff00d4);
	/* background image */
	/* background-image: url(/images/mask-image.jpg);*/
	-webkit-background-clip: text;
	background-clip: text;
	display: inline-block;
}

Gradient or image inside the letters

To fill the inside of stroked text with a gradient or photo, make the text fill transparent with color: transparent and -webkit-text-fill-color: transparent. Add your gradient or image as the element background, then clip it to glyphs using background-clip: text (plus the WebKit-prefixed clip).

Keep a visible stroke by setting -webkit-text-stroke-color to a solid color (often black or white) while the fill stays transparent. Multi-stop gradients create rainbow headline effects; photos need background-size and background-position tweaks so the subject sits inside the letters.

Use the generator background controls with BG fill mode to preview gradient or image fills alongside your stroke settings, then copy the combined CSS.

How Can I Add Text Stroke Background With An Image Or Gradient

To fill a gradient or image to a text stroke Background, first set the text color to transparent and -webkit-text-fill-color to transparent. Then, add two CSS properties: background-clip: text; and background: linear-gradient(0deg, #00e7ff, #ff00d4);.

Example Stroke background fill gradient and image

Preview stoke text fill gradient

Gradient Stroke

Preview stoke text fill image

Image Stroke

Here is how you can structure your CSS:

HTML
<h1 class="text-stoke-fill-gradient">Stroke Fill Gradient</h1>
CSS
.text-stoke-fill-gradient {
	font-size: 75px;
	-webkit-text-stroke-width: 1.5px;
	-webkit-text-stroke-color: #000;
	-webkit-text-fill-color: transparent;
	font-family: 'Arial Black', Gadget, sans-serif;
	/* gradient */
	background: linear-gradient(45deg, #9c27b0, #f44336, #ff9800, #ffc107, #8bc34a, #4caf50, #2196f3, #03a9f4, #00bcd4, #009688);
	/* background image */
	/* background-image: url(/images/mask-image.jpg);*/
	-webkit-background-clip: text;
	background-clip: text;
	display: inline-block;
}

Browser support

-webkit-text-stroke originated in WebKit engines and now works in current Chrome, Safari, Edge, and Firefox releases for typical outline styling. Always test clipped gradient and image combinations because background-clip: text still relies on prefixed properties in some browsers.

  • Chrome, Edge, and Safari: stroke and text clipping are widely supported with WebKit prefixes where needed.
  • Firefox: supports text stroke and standard background-clip: text in modern versions.
  • Legacy browsers without clipping may show solid fill colors only; provide a readable fallback color.

Frequently asked questions

Common questions about CSS text stroke, gradients, and the generator on this page.

What does -webkit-text-stroke do?

It draws an outline around each text glyph. Width and color can be set separately or with the shorthand. The inner fill still uses color or -webkit-text-fill-color unless you make the fill transparent for clipping effects.

How do I put a gradient on the stroke outline?

Set -webkit-text-stroke-color to transparent, assign a gradient or image to the background, and clip it to text with background-clip: text. Increase stroke width so the colored outline band stays visible.

How is text stroke different from text-shadow?

Text stroke follows the glyph outline uniformly. text-shadow offsets a painted shadow behind the text and can stack multiple soft layers. Use stroke for crisp outlines and shadow for depth or glow.

Can I fill letters with an image and keep a stroke?

Yes. Make the fill transparent, clip a background image to the text, and keep a solid -webkit-text-stroke-color so the border remains visible around the photo fill.

Does the generator support Google Fonts?

Yes. Choose a system font from the list or open the Google Font picker, load a family, and the tool adds the required link tag to the exported code when needed.

Combine stroked type with these typography and effect generators.