How do we know what energies (wavelengths) light contains? One way to find out is to disperse the light into its constituent wavelengths (colors or energies). When light is passed through a prism or spectrograph, for example, it is segregated according to wavelength, as illustrated in the following image.
Continuum, Emission, and Absorption Spectra

The resulting spectrum may exhibit a continuum (a continuous blend of colors), or it may exhibit bright lines (an emission spectrum) or dark lines (an absorption spectrum), as illustrated in the following figure.
Origin of Continuum, Emission, and Absorption Spectra

The origins of these three types of spectra are illustrated in the following figure.
A continuous spectrum comes from high density objects.  Such objects are called "blackbodies" in physics.  There is emission at every wavelength.  But there will be a wavelength where the emission peaks.  That tells you the temperature of the object.  The hotter it is, the more the emission peaks towards shorter wavelengths.  Thus, if such an object appears blue, it is hotter than one that appears red.  The colors of stars are an example of this.  Their color tells you their temperature.  This is called Wien's Law.  For two objects of the same size, the hotter one will also be brighter.

An emission spectrum is produced by thin gases at high temperatures.    If hot enough, the collisions between atoms will excite their electrons to higher energy levels.  Soon they return to lower energy levels, and every such downward transition results in a photon being emitted with a certain energy (or wavelength).  Hot clouds of interstellar gas show such spectra.  Each element has its own spectrum because each element has its own set of energy levels.
 
An
absorption spectrum occurs when light with a continuous spectrum passes through a cold, thin gas and atoms in the gas absorb only certain kinds of photons (only particular colors); this gives rise to dark lines (absence of light) in the spectrum.  A star shows such lines superposed on its continuous spectrum.