Want to impress your friends in the midst of a fireworks display? Wow them with your knowledge of basic chemistry and let them in on the secrets to the rainbow beauty of the night sky on the Fourth of July.

Small pellets, charmingly named "stars," are the key to the fireworks's colors, EarthSky reports. The stars are filled with different combinations of metal salts that each add a bright color to the firework when it explodes.

Different chemical elements correspond with different colors: strontium carbonate for red, calcium chloride for orange, sodium nitrate for yellow, barium chloride for green, and copper chloride for blue. Purple fireworks are created much like you might create purple paint—by mixing red and blue.

According to LiveScience, when you light the fuse on the outside of the fireworks's thick tube, the flame ignites a pouch of black powder inside known as the lift charge, which causes the shell containing the stars to catapult into the air. As it rises, a time-delay fuse begins to burn within it and, by the time it reaches its maximum height, the shell bursts, causing the stars inside to color each strand of the explosion.

Paul Nicholas Worsey, fireworks expert and professor of mining and nuclear engineering at the University of Missouri at Rolla, told LiveScience that red and green are the easiest colors to create, while blue is more difficult. Worsey says gold is best if you want your firework to keep its color for a long time, maybe even until it hits the ground.

The trick behind those especially crowd-pleasing fireworks that change color after they explode is simple: The stars are simply coated in multiple metal salts. Once you see the firework’s second color, that means the stars burned through their outer layer and reached a different metal salt—kind of like licking a Gobstopper.

For another way to impress your friends this fireworks season, learn the names of these 10 fireworks effects so you can call them out as they burst.

[h/t EarthSky]