Sir, yes sir! I’m agreeing with you, but I don’t think everybody do. You should not be so rude, it frightens of.
During my work as frontend coder I had a task to place some white text on dynamic background image and the problems would accrue if background image was white so text wouldn’t be readable. This isn’t really every day requirement but it can be very useful. The solution I’m using is outline text JS, originally written by Anthony Ryan Delorie.
You can use this JavaScript in two ways, to outline text and to add shadow to text. It works in all major browsers. Click here for demo.

<script> <!-- var message="outline"; var thickness=1; var color2="black"; var color1="white"; var extra="font-size:40px;"; var x = -thickness; var y = -thickness; while (y<=thickness) { while (x<=thickness) { document.write ("<span style='"+extra+" color:"+color2+"; position:absolute; left:"+x+"; top:"+(-y)+";'>"+message+"</span>"); document.write ("<span style='"+extra+" color:"+color2+"; position:absolute; left:"+x+"; top:0;'>"+message+"</span>"); document.write ("<span style='"+extra+" color:"+color2+"; position:absolute; left:"+x+"; top:"+y+";'>"+message+"</span>"); x=x+1; } y=y+1; } document.write ("<span style='"+extra+" color:"+color1+"; position:absolute; left:0; top:0;'>"+message+"</span>"); //--> </script>
<script> <!-- var message="Shadow"; var range=2; var extra="font-size:40px;"; var color1="gray"; var color2="black"; var x = range; var y = range; document.write ("<span style='"+extra+" color:"+color2+"; position:absolute\; left:"+x+"; top:"+y+";'>"+message+"</span>"); document.write ("<span style='"+extra+" color:"+color1+"; position:absolute; left:0; top:0;'>"+message+"</span>"); //--> </script>
<script> <!-- var message="Both"; var thickness=1; var color2="black"; var color1="white"; var color3="gray"; var extra="font-size:40px;"; var range=5; var z = range; var d = range; var x = -thickness; var y = -thickness; while (y<=thickness) { while (x<=thickness) { document.write ("<span style='"+extra+" color:"+color2+"; position:absolute; left:"+x+"; top:"+(-y)+";'>"+message+"</span>"); document.write ("<span style='"+extra+" color:"+color2+"; position:absolute; left:"+x+"; top:0;'>"+message+"</span>"); document.write ("<span style='"+extra+" color:"+color2+"; position:absolute; left:"+x+"; top:"+y+";'>"+message+"</span>"); x=x+1; } y=y+1; } document.write ("<span style='"+extra+" color:"+color3+"; position:absolute\; left:"+z+"; top:"+d+";'>"+message+"</span>"); document.write ("<span style='"+extra+" color:"+color1+"; position:absolute; left:0; top:0;'>"+message+"</span>"); //--> </script>
NOTE: It’s not working when doctype -> XHTML 1.0 is included
Sir, yes sir! I’m agreeing with you, but I don’t think everybody do. You should not be so rude, it frightens of.
Hi Anthony, thanks for visiting. I have used your code many times and i think that’s the only solution for this right now.
I’ve tried to find your home pages but i guess there is no such so i just gave your name
If you are are interested in sharing some of the rest of your code feel free to contact me ![]()
wow. googled my name and found this blog.
thanks for the credit, i wrote that back in school. i wish i had shared more and gotten more into open sourcing my stuff and benefited more by getting my name out there. glad to see in 2008 people still getting use of a script i thought was cool at the time i wrote it.
I’d plug a blog, but i don’t maintain one frequently enough.
also glad to see the emergence of javascript over recent years.
Great article. Thanks for sharing it
@ Ty (tzmedia)
Good question, yes it is, I’ve written code for it and updated demo and source.
About the original author, no i don’t know if there are some other examples, and if there are they should match my b/c code is pretty much the same.
that’s pretty cool, I commonly use photoshop layers to produce graphics, either stroke or a heavy outer glow. Too many times letters don’t stand out on a various color background image.
Q: Can both effects be applied at the same time?
Like black letter outline, grey drop shadow?
thanks.
you credit someone else with the technique, are there any links of more demo’s from them?
on April 9, 2008
Lovely post. I like your pencraft and that