The creation of a beautiful fireworks display is the result of both science and art. Fireworks require at a minimum: fuel, an oxygen producer, color producer and binder to hold everything where it should be, in addition to propellants and any special effects that might be desired.
The fireworks color is the result of heating metal salts that emit colors characteristic of that element. The atoms of the element first absorb energy and then release it as a specific colored light. Some salts required to produce the desired color are unstable and must be combined with a more stable compound. This stabilizing compound may, in some cases, be required to break down as in the case of producing the color green with barium chloride. Since barium chloride is not stable at room temperatures, barium is combined with chlorinated rubber (stabilizing compound) and when heated the chlorine is released and combines with barium chloride to produce green fireworks.
There are two types of color production in a firework, incandescence and luminescence; incandescence is light produced from heat while luminescence is light, sometimes called cold light, produced using energy sources other then heat. With incandescence light, as substances are heated, their glow increases as heat increases emitting first infrared, followed by red, orange yellow and finally white light. Luminescence is produced when energy is absorbed by electrons resulting in the electrons going into an unstable state of excitement. As the energy is absorbed by the molecule the electrons in the atoms rearrange from their lowest energy rate to a higher energy state. As the electrons return to their original state they release the energy they had absorbed; in the form of photons (light).
How much energy a given elements will emit differs from element to element and is characterized by a specific wavelength of light and a corresponding color. Colors in the violet/blue part of the spectrum are the result of the shorter wavelength light that correspond to higher releases of energy. Lower energies produce longer wavelengths and colors from the orange red part of the spectrum.
The metal salts along with oxidizing agent, reducing agent, and binders are packed together into small (3 to 4 cm) clay or dough-like lumps or cubes referred to as stars. The stars are handmade and packed into compartments in the firework shell. Fireworks are made by hand because of the likelihood of machinery producing a spark and igniting the explosives.
When we look into the night sky on the Fourth of July, Memorial day, Guy Fawkes Day or when our favorite sports team has won a game we are filled with awe, as well we should be. A successful fireworks show requires artistic skill, careful planning, pyrotechnical knowledge and more then a passing knowledge of Chemistry.
Sources: http://chemistry.about.com/od/fireworkspyrotechnics/a/fireworkcolors.htm
http://scifun.chem.wisc.edu/CHEMWEEK/fireworks/fireworks.htm