Use CSS -webkit-text-stroke to outline live web text. For example, -webkit-text-stroke: 2px #000; sets a 2-pixel black stroke around the characters. Keep a readable text fill in color, and adjust the stroke for the typeface and size you actually use.
Apply a stroke to a heading
Put a class on the text element, then set its fill color and stroke:
<h1 class="title">Outlined heading</h1>
.title {
color: white;
-webkit-text-stroke: 1px black;
}
The -webkit-text-stroke shorthand sets both stroke width and color. Its initial width is 0, so setting only a stroke color does not make an outline visible. Its initial color is currentcolor. The property is inherited and applies to all elements. MDN Web Docs describes it as specifying the width and color of strokes for text characters.
Set width and color separately
Use the longhand properties if you want to keep the two settings distinct:
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
.title {
-webkit-text-stroke-width: 1px;
-webkit-text-stroke-color: black;
}
The width is a length and the color accepts a CSS color. The shorthand is equivalent to setting -webkit-text-stroke-width and -webkit-text-stroke-color.
Use feature detection when needed
If you want to apply the outline only when a browser recognizes text-stroke syntax, use an @supports query. Checking both spellings follows the pattern documented in MDN’s @supports guide:
Rank #2
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
.title {
color: white;
}
@supports (text-stroke: 1px) or (-webkit-text-stroke: 1px) {
.title {
-webkit-text-stroke: 1px black;
}
}
The base color remains in place if the query does not match. A restrained text-shadow can also help maintain contrast in some designs, but check the rendered result with the fonts, sizes, and browsers you support.
Check browser support and text legibility
MDN marks -webkit-text-stroke as “Baseline: Widely available,” reporting support across many devices and browser versions since April 2017. Its page, last modified September 10, 2026, also notes that formal syntax reflects CSS Borders and Box Decorations Module Level 4 and that not every browser may implement every part. See MDN’s compatibility and syntax notes.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →Rank #3
- Start with a modest stroke width. Heavy strokes can crowd the open spaces and joins in letters, particularly at small sizes.
- Check the final glyph edges, fill, and background together; the outline’s color alone does not determine readability.
- Do not use a decorative outline as the sole way to communicate meaning.
- Inspect the result in your target browsers and fonts, because font rendering affects how the outline looks.
Choose CSS stroke for live text
CSS stroke is a practical choice when you want selectable, live text with a simple outline and control over its width and color. It does not guarantee identical rendering across all browser and font combinations, so visual checking matters. If the requirement is a fixed, art-directed letterform rather than ordinary live text, an image or SVG may be more appropriate.
Quick Recap
Best Value
Rank #4
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

