The spectrum
A diffraction grating has a fine pattern of grooves on it (1/10000" apart -- much too fine to see). These deflect light of different frequencies in different directions. If the light is a mixture of different frequencies, this will separate them.
The color effects of oil films on water and soap bubbles are also diffraction effects. In each case, the film of oil or soapy water is so thin that the different frequencies of light are reflected differing amounts.
Light of different frequencies is perceived by the eye as light of different colors. However, where the eye can really only detect three colors of light (more about this later), we can subdivide the spectrum indefinitely -- every different direction that you look, you are seeing light of a slightly different frequency. With a good spectroscope there are thousands of distinguishable frequencies -- to a physicist, there are thousands of colors of visible light.

Atoms that are excited by being in a spark give off light, with a spectrum that is specific for the kind of atom. This is how astronomers know what stars are made of: they can detect these spectra in the starlight, just as we can detect the mercury discharge that is hiding inside a fluorescent lamp.

Color and Spectrum

Light of different wavelengths appear to be different colors
It is conventional to assign seven color names to the spectrum (other cultures have divided it in other ways, however), though we can distinguish far more shades than that. The spacing of the "seven colors" is not uniform within the spectrum as made by a diffraction grating. And as we will learn elsewhere, we also assign colors to light that is a mixture of different wavelengths.

Sunlight and the light from an incandescent bulb (a glowing hot wire) contains all wavelengths, but many light sources have complex spectra, with some wavelengths present and others missing. For example, the newer fluorescent lights have a spectrum that looks like this:


where the incandescent spectrum is placed next to it for comparison (the colors in the photograph are not right, because the camera doesn't interpret light of a single wavelength correctly. But the positions of the colored bands is right).

Invisible light