A flame test is an analytic procedure used in chemistry to detect the presence of certain elements, primarily metal ions, based on each element's characteristic emission spectrum. The color of flames in general also depends on temperature; see flame color.
The test involves introducing a sample of the element or compound to a hot, non-luminous flame, and observing the color of the flame that results. The idea of the test is that sample atoms evaporate and since they are hot, they emit light when being in flame. Bulk sample emits light too, but its light is not good for analysis. Bulk sample emits light primarily due to motion of the atoms, therefore its spectrum is broad, consisting of a broad range of colors. Separate atoms of sample present in flame can emit only due to electronic transitions between different atomic energy levels. Those transitions emit light of very specific frequencies, characteristic of chemical element itself. Therefore, the flame gets the color, which is primarily determined by properties of the chemical element of the substance being put into flame. The flame test is a relatively easy experiment to set up, and thus is often demonstrated or carried out in science classes in schools.
Samples are usually held on a platinum wire cleaned repeatedly with hydrochloric acid to remove traces of previous analytes. The compound is usually made into a paste with concentrated hydrochloric acid, as metal halides, being volatile, give better results. Different flames should be tried to avoid wrong data due to "contaminated" flames, or occasionally to verify the accuracy of the color. In high-school chemistry courses, wooden splints are sometimes used, mostly because solutions can be dried onto them, and they are inexpensive. Nichrome wire is also sometimes used. When using a splint, one must be careful to wave the splint through the flame rather than holding it in the flame for extended periods, to avoid setting the splint itself on fire. The use of cotton swab or melamine foam (used in "eraser" cleaning sponges) as a support have also been suggested.