Text shadows using a DOM script

Without any extra markup and it degrades rather nicely.

A heading

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.

And a link with a nice shadow.

The basic script

This is a very simple example. I'll probably improve it sometime.

function applyShadow(targetElement, shadowColor, shadowOffset) {
  if (typeof(targetElement) != 'object') {
    targetElement = document.getElementById(targetElement);
  var value = targetElement.firstChild.nodeValue;
  targetElement.style.position = 'relative';
  targetElement.style.zIndex = 1;
  var newEl = document.createElement('span');
  newEl.className = 'shadowed';
  newEl.style.color = shadowColor;
  newEl.style.position = 'absolute';
  newEl.style.left = shadowOffset + 'px';
  newEl.style.top = shadowOffset + 'px';
  newEl.style.zIndex = -1;

And you call it like this:

applyShadow('heading', '#ccc', 2);
applyShadow('lipsum', '#c33', 1);

for (var i = 0; i < document.getElementById('list').getElementsByTagName('li').length; i++) {
  applyShadow(document.getElementById('list').getElementsByTagName('li')[i], '#aaa', 1);

Home - More stuff