Unlock the Power of Stroked Text: A Comprehensive Guide
Stroked text, also known as outlined text, can elevate your webpage’s design by making letters stand out from the background. This versatile technique can be employed in various ways to add a unique aesthetic to your website. In this article, we’ll delve into the world of stroked text, exploring its applications, methods, and best practices.
What is Stroked Text?
A stroke is a border drawn along the outline of a letter. Stroked text can bring a distinct visual appeal to your webpage, reminiscent of American football jerseys or heavy metal album cover art. The stroke can have a color different from the fill, and its width can vary, similar to a border.
Where to Use Stroked Text
Stroked text is not commonly seen on the web, but it’s used in various ways to create striking visuals. You can find it in fashion, comics, and even in promotional campaigns, like Costa Coffee’s ads. IMDb’s “Top Series of 2022” article is a great example of mixed typographic style, where stroked text is used to create an eye-catching contrast.
Creating Stroked Text in CSS
There are three methods to create stroked text in CSS:
- The Non-Standard
-webkit-text-stroke
Property: This property specifies the width and color of a stroke for text content. Although it’s well-supported in modern browsers, it’s a non-standard property, which may be removed in the future. - The Shadow Hack: This method uses the
text-shadow
property to simulate a stroke. However, it’s messy and prone to errors, making it less desirable. - The Pseudo-Element Hack: This approach uses a CSS pseudo-element to create a surrogate element that serves as the stroke. Although it does a decent job, it requires duplicating text content and has some drawbacks.
Stroked Text in SVGs
SVGs offer a standard way to create stroked text using the stroke
, stroke-width
, and fill
attributes. This approach provides more control over the stroke, allowing for dashed stroked text with stroke-dasharray
. IMDb uses an SVG for the “2022” text in their “Top Series of 2022” title, but unfortunately, it’s not accessible.
Stroked Text with Variable Fonts
Some fonts, like the Star Jedi Font, offer a stroked variant. Variable fonts can create stroked text through custom axes or features. The dT Jakob Variable Concept font is an example of a font that can create inline, shape, and shadow versions of text.
Creating Stroked Text with CSS vs. SVGs
While CSS methods can create stroked text, they’re often unreliable and unwieldy. SVGs offer a standard, consistent approach with more control over the stroke. However, creating stroked text with SVGs can be finicky and requires careful setup.
Closing Thoughts
Creating beautiful outlined text is possible, but the methods can be unreliable and unwieldy. Using a non-standard property or hack is not ideal. Fortunately, transparent stroked text appears to render reliably across browsers. We hope for a W3C-approved CSS stroke property soon. For now, using SVGs is the recommended approach to create stroked text.