Flame color depends on two things: the temperature of the flame and the material being burned.
Anyone who’s watched a burner on an old-style electric stove knows that color can change with temperature. Turn the burner on high to warm a pot of soup, and the cool black coils slowly begin to glow. A bit of dark red creeps in, gradually changing to a bright orange-red, meaning hot-hot-hot.
While electric stove coils can get very hot, the burner is not really burning—it’s not on fire. It’s just getting very hot. If those coils were a chunk of steel heated to even higher temperatures in a blast furnace, the color would progress to a brilliant yellowish-white.
But the colors of a burning candle flame also depend, at least in part, on temperature.
Fires need oxygen. (If you put a jar over a candle, the flame will die out.) When a candle is burning, the middle of the flame isn’t getting much oxygen. So it looks darker. But the outside and top of the flame, which get lots of air, burn bright.
As the wick burns and the wax melts, bits of carbon fly up. These teeny pieces of carbon, heated, glow like hot coals in a grill—or like the coils of your electric stove. But since a typical candle flame is hotter than the burner on an electric stove—more than 2,500°F (1,371°C)—it glows yellow instead of red. This is what makes candle flames mostly yellow. Near the burning wick, in the actual reaction or combustion zone, the flame is hottest of all—and therefore blue.
A gas stove runs on natural gas or propane, which burn purely and cleanly, with little or no soot to glow yellow. So a gas stove has a blue flame. (Solid yellow flames mean something’s wrong; call the gas company.)
Spill a little salt into a blue gas flame, and it will also flare yellow. Why? Heated in a flame, the sodium in table salt emits bright yellow light.
Different metals and metallic salts emit different wavelengths (colors) of light when heated in a flame. Electrons in the chemical get excited and gain energy, rather like corn popping in a microwave. When the electrons return to their normal energy levels, they release the excess energy as photons of light. While sodium atoms give off yellow light, different forms of copper emit higher-energy green or blue-green light.
A wood fire, which usually burns at a lower temperature than a candle, is often a warmer orange-yellow. Calcium salts, phosphorus, and other elements in wood or in materials thrown on the fire add their own signature colors—like red and blue-green—to the crackling flames.
Scientists can even use a flame test to identify some chemicals. Potassium iodide sprinkled into a Bunsen burner will make the flame violet; barium will turn it green.
Minerals like calcium, sodium, and copper, heated to high temperatures, give exploding fireworks their brilliant colors.