Complete combustion of candle wax leads to the formation of heat, light, carbon dioxide and water. Soot and smoke also form in instances where the candle wax does not burn completely.
Candle wax is mainly connected chains of carbon and hydrogen atoms, known as hydrocarbon molecules. Once a candle is alight, the heat from the flame melts the wax surrounding the wick, turning it into a liquid that then moves up the wick by capillary action. The flame's heat vaporizes the liquid wax, leading to the breakdown of hydrocarbon molecules into individual molecules of hydrogen and carbon. The carbon and hydrogen molecules react with oxygen from the surrounding air to form carbon dioxide, water, heat and light. The heat radiates back to the wax and melts it to form a cycle that continues until the heat is eliminated or the wax is used up.
When a candle flame receives inadequate or excessive air or fuel it flickers causing unburnt carbon molecules to escape from the flame before they can fully combust. The tiny particles of solid, unburned carbon molecules escape from the flame as smoke. A black stain forms when the carbon molecules come into contact with a nearby wall or on the ceiling above the candle.