Firework displays will dazzle Americans from coast to coast this Thursday. But while you might have Thomas Jefferson to thank for the Declaration of Independence -- and by extension, the Fourth of July -- it’s chemistry that powers those colorful explosions in the sky.

Fireworks display different colors due to the various kinds of materials packed inside them. When certain metals are heated to a certain temperature, electrons momentarily jump to a different energy level. When the electron settles back down to its original energy level, that cooling process emits a photon. Depending on the material, the photon will have a different wavelength and, hence, a different color.

For instance, while sodium appears gunmetal gray in person:

[[nid:1332437]]

It creates bright yellow light when it burns:

[[nid:1332435]]

You can see this effect in sodium lamps as well:

[[nid:1332407]]

Barium, which when compounded with sulfur and oxygen is used in X-ray imaging of the digestive system, is also used in fireworks to produce a green color. Yellowish green colors come from the compound barium chloride; barium nitrate gives a brighter green.

[[nid:1332405]]

The element strontium was primarily used in the production of glass for color TVs and computer monitors, thanks to its X-ray-shielding properties. It can also give fireworks a deep red color.

[[nid:1332403]]

Blue was a tricky color for pyrotechnicians for some time, since the traditional material used, copper chloride, didn’t survive well enough at high heat to produce a vibrant display. But in recent decades, makers of fireworks have found success with a magnesium-aluminum alloy called magnalium.

[[nid:1332399]]

Other substances besides the color-generating material are also used in fireworks. To slow or speed the burn rate, pyrotechnicians can add sulfur or sugars (to make it burn faster) or salt (to slow it down).