While you're being wowed by Fourth of July fireworks on Wednesday, your mind might not be dwelling on chemistry -- but without chemical reactions, those rockets wouldn't have their red glare.

The brilliant colors of fireworks come from the burning of different kinds of material. When certain metals are heated to a certain temperature, it causes electrons to momentarily jump to a different energy level. Once 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.

Some of the easiest firework colors to make are yellow, made by burning sodium; green, with barium; white, with titanium; and red, with strontium.

For many years, pyrotechnicians struggled with the color blue. The traditional material used to make blue shades was copper chloride, but it didn't survive very well at high heat, resulting in a less vibrant color display. But in recent decades, firework-makers have hit upon a solution: a magnesium-aluminum alloy called magnalium that produces a true blue and can add a fluorescent glow to other colors as well.

The compounds that are burned to generate light are usually made up of little spherical pellets, often called stars. But the color-generating material isn't the only thing in the star -- most of the compounds that create colors retain a lot of moisture, making them damp and unstable. To remedy this, firework makers usually add a compound containing chlorine to the mixture to stabilize and enhance the color of the burning metal.

Since they burn from the outside inward, pyrotechnicians can create color changes by creating a star with a center of one material surrounded by a layer of another material.

Of course, the color-generating part of the firework is just one component of the device. Most display fireworks typically have three other parts: a charge made of black powder to propel the firework from a mortar tube, a delay fuse that burns while the firework is lofted higher into the sky and a break charge that explodes and scatters the contents of the shell.

To create fancy shapes such as hearts and smiley faces, the pellets are arranged in the shape to be seared into the sky and pasted onto a piece of paper or arranged within the shell. As the firework explodes, the pellets fly outward in that same arrangement.

Some fireworks can also produce a whistling or screaming sound. The process to generate sounds in a firework is similar to how a teapot whistles. Whereas the teapot's whistle comes from steam escaping through a small hole, the whistle of a firework is made when a firework is constructed in a tube with an open end. As the firework's fuel burns off, it generates carbon dioxide gas, which exits through the open end of the tube and produces a noise.

The explosive reactions of fireworks are really hot -- usually more than 3,632 Fahrenheit, according to Paul Nicholas Worsey, a professor of mining engineering at the University of Missouri at Rolla, who penned a short treatise on firework science for Scientific American in 2003.

Other factors can increase or decrease the speed at which a firework burns, according to Worsey. Smaller stars and the addition of accelerants such as sulfur or sugars make for a faster burn, while salt can slow a reaction.