The rainbow seen in the sky is actually the spectrum of the
Sun. Rainbows can also be created by passing light from an
incadescent bulb (for example) through a prism. If one looks
carefully at the spectrum of the Sun (a very dispersed spectrum -
the rainbow outside won't do), one notices that the it is not a
complete rainbow, like the lightbulb. There are sections of the
spectrum that are missing.
These missing sections a the result of atoms between you and the core of the Sun that have absorbed very specific colors of light. To understand why this happens, let us learn a little about how atoms work. We will return to the rainbow of the Sun later.
If one takes a tube filled with, say, hydrogen (or any element or chemical) and runs electricity through it, the tube will glow with a very unique color. Passing this light through a prism (or similar device), you will find that the "rainbow" of the element is composed of discrete and completely unique pattern of colors. This uniqueness of an extremely powerful tool - it is a fingerprint that can be used to identify a particular (any!) element or chemical - hydrogen, helium, lithium, sodium chloride (table salt), carbon dioxide (the stuff you exhale), oxyhemoglobin (the stuff that makes your blood red), chlorophyll (the stuff that makes plant green), methane, amonia, etc.