If you look at table salt (NaCl) being heated by a Bunsen burner flame, you will see a very bright yellow color in the resulting flame.
This yellow is a characteristic footprint of the element sodium, Na, of which salt, NaCl, is comprised.
The more general technique of looking at the spectrum of light emitted (and absorbed) by a substance to identify its constituent atoms and molecules is known as spectroscopy.
The light is generated when the atom makes a transition from a high energy state to a lower energy state, and the difference in energy is converted into a photon (*). Typically, it is the electrons in the atom that undergo a transition, but other types of transitions are possible, as we shall see.
If an atom makes a transition from a state of energy Einitial to a lower state of energy Efinal,
the photon that is emitted can have a frequency given by w = (Eintial - Efinal)/hbar
where hbar is Planck's constant divided by 2 pi :
Arbitrary transitions are not allowed, but only those permitted by the rules of
quantum mechanics, and so each element has a distinct spectrum that correspond to
allowed transitions between its energy states. It is for this reason that we can
use light spectra to uniquely identify an element.
Here for example is the emission spectrum of sodium (Na):
Sodium line spectrum
Notice the lines have a finite thickness, which corresponds to an uncertainty in the frequency of the measured light. There can be a number of causes for this "line broadening". Natural line broadening, which is unavoidable, is a result of the fundamental limitation imposed by the Heisenberg time-energy uncertainty principle. Other sources of broadening are Doppler broadening and pressure broadening.
Typically, the light emitted is due to the electrons undergoing a transition in the atom. However, it is also possible the change in energy of the atom is due to a nuclear transition.
For nuclear transitions, the photons will normally have a larger energy (typically, the photons will correspond to gamma rays) and so will have a larger momentum than the photons emitted due to electronic transitions. Since conservation of energy and momentum must be obeyed, this large momentum introduces a new source of broadening -- not all of the Einitial - Efinal energy is available for the emitted photon, but some of it must go to the kinetic energy of the nucleus. This transfer of energy to the nucleus represents another source of line broadening.`
Amazingly, Mossbauer discovered in the case of atoms bound in a crystal lattice, it is possible to have what in effect appears as a "recoilless emission" of gamma rays from the nucleus, so that we don't get this broadening.
The Mossbauer Effect was discovered by Mossbauer in 1957 (although Willis Lamb had predicted it much earlier) and for this he received the Nobel Prize in 1961. The Mossbauer Effect is a powerful tool in a variety of branches of physics, including general relativity. Here and also here you can see Mossbauer spectroscopy being used to study the Martian soil and atomospheric dust from data being sent back from the Mars Exploration Rover Spirit.
* There is still one other way light in which light may be "emitted" by an atom, and that is by the process of elastic scattering of a photon from the atom.