Potassium burning in a flame producing a lilac flame. The colour of the flame is caused by electrons that have been excited to a higher energy state. When they relax they emit energy in the form of a characteristic wavelength of light. The colour of the flame is different for different elements and can be used to identify unknown substances.