Software, your way.
How To Get Good Custom Software
(Download)
(PDF)
burger menu icon
WillMaster

WillMaster > LibraryWebsite Development and Maintenance

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!

Shadow for Text Characters

Text characters can have shadow like images, divs, and other HTML elements can have shadows.

Like Borders for Text Characters, shadow is specified with CSS. No JavaScript required.

The shadow's position, thickness, and color all can be customized.

We'll do a few examples. Following the examples is a text character shadow tool you can use to see the effect of certain CSS declarations you wish to try.

For consistency (and for contrast), all the example text is blue (#0000ff) and the shadow is a pale red (#ffcccc).

Here is the first example.

Hello World!

The horizontal shift is 2 pixels right. And the vertical shift is 5 pixels down.

Here is another example.

Hello World!

The only difference between this and the first example is a blur radius of 3 pixels.

This third example has the shadow slightly to the left and far up.

Hello World!

The horizontal shift is 4 pixels left. And the vertical shift is 20 pixels up.

And one more example, after which we'll to the "how to do it" part.

Hello World!

The only difference between this and the third example is a blur radius of 5 pixels.

There is a lot of room for creativity. Shadow position, shadow color, and the blur radius can all be changed to get the effect you're looking for.

How to Do It

The CSS text-shadow property is used. The value for the property is up to four parts, the first two being required and the last two being optional:

text-shadow: h-shadow v-shadow blur-radius color

Here is what the values mean.

  • h-shadow (required) — the amount of horizontal shift the shadow shall have. The amount may be 0 (zero). A negative number shifts the shadow to the left. A positive number to the right.

  • v-shadow (required) — the amount of vertical shift the shadow shall have. The amount may be 0 (zero). A negative number shifts the shadow up. A positive number down.

  • blur-radius (optional) — the amount of blur to effect on the shadow. Default is 0 (zero).

  • color (optional) — the color for the shadow. Default is the color of the text the shadow applies to.

(See Using CSS Snippets for information about implementing the CSS snippets on this page.)

The generator for text shadow (below) includes links generate the CSS used to build the above four examples.

A Tool to Generate the CSS for Character Shadow

A tool was created to design shadow for text characters and generate the CSS to implement the design.

Use the tool to specify your preferences. It will show you the result and give you the code for the CSS definitions.

Within the tool area, the box above the form is a preview. The box below the form contains the CSS style.

Text Character Shadow Tool

Tap anywhere outside the last-changed form field to update the Preview and the CSS. Note: Invalid values in form fields will not update the Preview.

The Preview

Hello World!
Recreate CSS definitions for:
example 1example 2example 3example 4

The Form

Example text:

Font size (pixels):
Font style:
Font weight:
Font family:
Font color:
Shadow horizontal:
Shadow vertical:
Shadow blur radius:
Shadow color:

The CSS

Being able to shadow text characters with custom colors, positions, and blurs brings wonderful design possibilities. Besides, as declared in Borders for Text Characters, it is just plain fun.

(This article first appeared with an issue of the 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