[X]

Rainbow Text

text effects 1997 still works

Colours every letter of a heading a different colour of the rainbow.

In 2026: Works fine. It writes with document.write, which only runs during page load, so keep it inline where you want the text.

Where it came from: Free script archives, late 90s. Too many near-identical copies to trace a first one. Wikipedia

<script language="JavaScript">
var colours = ["#FF0000","#FF7F00","#FFFF00","#00FF00",
               "#0000FF","#4B0082","#9400D3"];
function rainbow(text) {
  var out = "";
  for (var i = 0; i < text.length; i++) {
    out += '<font color="' + colours[i % colours.length] + '">'
         + text.charAt(i) + '</font>';
  }
  document.write(out);
}
</script>

<h1><script language="JavaScript">rainbow("MY HOME PAGE");</script></h1>
sandboxed demo · breaks nothing but itselfrestart

More in text effects

all 15 in text effects › · the whole library ›