CSS Text Stroke Generator
Generate outlined or hollow text with -webkit-text-stroke, including paint-order so a thick stroke does not eat the letters, and an optional text-shadow fallback.
Loading tool…
The CSS is generated by JavaScript in your browser and never leaves the page. There is nothing to upload and nothing is stored.
What the CSS Text Stroke Generator does
The CSS text stroke generator on this page will generate outlined or hollow text with -webkit-text-stroke, including paint-order so a thick stroke does not eat the letters, and an optional text-shadow fallback. Everything runs inside this page, so the work happens on your own device rather than on a server. It is most often used for hollow display headings for a hero section or a poster-style layout. If you want to cross-check the result, there is another CSS text stroke generator on FreeToolsWorld.org.
How to use it
- Type the text you want to preview, and set its size and weight.
- Set the stroke width and colour.
- Turn hollow text on for an outline only, or off to keep a fill colour inside the stroke.
- Add the text-shadow fallback if you need to support an engine without text-stroke, then copy the rule.
How it works
Despite the vendor prefix, -webkit-text-stroke works in every current browser — Chrome, Edge, Safari and Firefox all support it, and the prefix is simply the name it shipped under and kept. It takes a width and a colour, and with color: transparent it produces hollow text. That is the whole feature, and it is a great deal cleaner than the techniques that preceded it.
The detail that makes or breaks it is paint-order. By default the stroke is centred on the glyph outline, so half of its width is painted inside the letter and half outside. At 1px nobody notices; at 4px the counters close up and a bold typeface starts to look like a blob. paint-order: stroke fill draws the stroke first and the glyph on top of it, which puts the whole stroke width outside the letter shape and leaves the letterforms intact. It is one line, it is widely supported, and it is the difference between a thick outline looking deliberate and looking broken.
The text-shadow fallback is offered because some older engines, and a few embedded webviews, lack text-stroke entirely. Eight shadow offsets at the stroke width approximate an outline: up, down, left, right and the four diagonals. It is genuinely worse — eight offsets cannot round a corner, so joins go visibly lumpy past about 2px, and the shadows are painted outside the glyph with no way to control how they meet. Use it at 1 or 2px if you need the coverage, and otherwise rely on text-stroke, which is where the quality is.
For hollow text specifically, contrast is the thing that catches people. An outline with no fill reads as a thin line drawing, and a 1px stroke over a photograph or a busy background is close to invisible at body sizes. Hollow text wants to be large and the stroke wants to be at least 2px; below that, a solid fill with a contrasting stroke is more legible and keeps the effect. Remember too that a transparent fill is still text to a screen reader and still selectable, which is the main reason to do this in CSS rather than exporting an image.
Where an outline has to be perfectly controlled — a logo, a wordmark, anything where the join between strokes matters — SVG text with a stroke attribute and stroke-linejoin: round gives you control that CSS does not expose. For headings, hero text and anything that has to stay selectable and reflow, text-stroke is the right tool.
When to use it
- Hollow display headings for a hero section or a poster-style layout.
- Keeping text legible over a photograph without a solid background panel.
- An outlined numeral or letter as a decorative element.
- A hover state that fills in previously hollow text.
- Matching a design where the type has a deliberate outline.
Common mistakes to avoid
- Leaving paint-order out, so a thick stroke eats half its width out of the letters.
- Using a hollow style with a stroke under 2px, which disappears against anything busy.
- Relying on the text-shadow fallback at a large stroke width, where the joins go lumpy.
- Assuming -webkit-text-stroke is Safari-only. The prefix is historical; every current browser supports it.
- Exporting the text as an image instead, which loses selection, search and reflow.
Frequently asked questions
Does -webkit-text-stroke work in Firefox?
Yes. Every current browser supports it — Chrome, Edge, Safari and Firefox. The -webkit- prefix is the name the property shipped under and was never renamed; it is not an indication that the feature is WebKit-only.
What does paint-order: stroke fill do?
It draws the stroke before the glyph rather than centred on its outline, so the entire stroke width sits outside the letter instead of half inside it. Without it, a 4px stroke takes 2px out of every letter and closes up the counters in a bold face.
How do I make hollow text?
Set color: transparent and give the text a -webkit-text-stroke. The glyphs are still real text — selectable, searchable and readable by a screen reader — which is the reason to do it this way rather than exporting an image.
Is the text-shadow fallback any good?
At 1 or 2px it is acceptable. Beyond that it looks visibly wrong, because eight shadow offsets cannot produce a rounded or mitred join and the corners go lumpy. It exists for engines without text-stroke, not as an equal alternative.
When should I use SVG text instead?
When the outline itself has to be precise — a logo, a wordmark, or anywhere the joins between strokes are part of the design. SVG exposes stroke-linejoin and stroke-linecap, which CSS text-stroke does not. For headings that must reflow and stay selectable, CSS is the better choice.