Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWeb Content Preparation

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Stroking Text

Text can be stroked with a different (or same) color. The stroke can be any practical thickness.

A text stroke can be likened to a border around text characters.

Almost like that. Visualize a brush stroke around the edge of a text character. Part of the stroke is within the edge of the character and part is on the outside.

The wider the stroke, the more it covers the edge of the characters and the more it spills outside the edge.

Here is a repeated character, all the same specified color but with various widths of text strokes.

H H H H H

The first of the above characters has no stroke. The next has a 1-pixel stroke. After that, each subsequent character has a stroke double the width of the previous. The last character has an 8-pixel stroke.

Here is the source code for the above example.

<p style="margin:0; font-size:50pt; line-height:100%;">
<span style="color:pink;">H</span>
<span style="color:pink; -webkit-text-stroke:1px blue;">H</span>
<span style="color:pink; -webkit-text-stroke:2px blue;">H</span>
<span style="color:pink; -webkit-text-stroke:4px blue;">H</span>
<span style="color:pink; -webkit-text-stroke:8px blue;">H</span>
</p>

The CSS property -webkit-text-stroke is used to specify a text stroke.

The -webkit-text-stroke property requires two values, the width of the stroke and the color of the stroke. You'll see the values specifed in the above example source code.

An illustration of use: If the text color is specified as transparent and the stroke color as white (or other suitable color), you'll have transparent outlined text. Here is an illustration of text created with color:transparent; and -webkit-text-stroke:1px white; CSS definitions, on top of a color-gradient image.

Image with 'Text'
Text

For completion, here is the source code of the entire above illustration.

<div style="max-width:300px; position:relative;">
<img src="https://willmaster.com/possibilities/images/poss1255(css).png" alt="Image with 'Text'">
<div style="color:transparent; -webkit-text-stroke:1px white; position:absolute; left:0; right:0; top:20px; text-align:center; font-size:123px;">Text</div>
</div>

Generally, because the stroke is partially over the edge of characters, the -webkit-text-stroke property is more suitable for larger text.

(This content first appeared in Possibilities newsletter.)

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC