Keep an opaque fill available for outline lettering
Admin ·
An outline runs along the shape of each glyph. Set the stroke and fill independently, and check that the wording remains legible at the size you will use.
Compare filled and outline-only lettering
Select Reset example. Outline type uses a two-pixel stroke in #243B53 and a solid #B45309 fill. Select Outline only. A supporting browser keeps the outline and lets the preview background show through the glyph interior.
Switch the Preview background to Dark and compare how much of each letter remains readable. The preview background choice stays in the workspace.
| Mode | Stroke width | Fill in a supporting browser |
|---|---|---|
| Filled | 2 px | #B45309 |
| Outline only | 2 px | Transparent |
Check what happens outside the feature query
Download text-stroke.css and assign tm-stroke-text to the element. The base class declares the opaque fill color. The outline-only rule switches the fill to transparent only when the CSS stroke declaration is supported.
The forced-color rule restores the system text color to keep the phrase available without the decorative outline.
W3C CSS Conditional Rules Level 3, feature queriesW3C CSS Color Adjustment Level 1, forced colors
Check the shape of narrow letters
Replace the sample text with your final heading. Try increasing the stroke width from 2 to 4 pixels and review openings in letters such as e and a. Narrow interior details can get smaller as the stroke grows.
Use a smaller outline width or a wider-weight font when small openings become hard to see. In filled mode, a width of zero leaves the opaque fill.
Common questions
Does the stroke property draw a border around the entire element?
It follows the painted glyphs. For a border around the element’s box, use the CSS border property.
How do I get an outline with a softer color?
Enter a stroke color with hex alpha. Keep some alpha and a positive width when using Outline only.