From "I fucking love science":
The chemistry of 4th July fireworks.
Sodium produces yellow/gold colors. Barium creates green, copper compounds produce blue, strontium salts give you red and titanium metals give you silver coloured sparks.
Other commonly used chemicals are carbon which provides the fuel, oxidizers which produce oxygen for burning, magnesium which increases the overall brilliance and brightness, antimony that gives you a "glitter" effect and calcium which deepens the colors.