The spectra observed from galaxies are formed from a combination of stars, molecular clouds, and star-forming regions. We can examine them to determine many properties, among them the radial velocity of the galaxy, the star-formation rate, and the average age and metallicity of the stellar populations, and the kinematics (mass) of the galaxy. A spectrum has three components: the continuum, absorption lines, and emission lines.

Continuum spectrum
Continuous spectra (also called thermal or blackbody spectra) arise from dense gases or solid objects which radiate heat. They emit radiation over a broad range of wavelengths, thus the spectra appear smooth and continuous. Stellar cores emit light in a predominantly continuous spectrum, as do incandescent light bulbs, electric cooking stove burners, flames, fire embers, and ... you.
[NMSU, N. Vogt]

Emission spectrum
Discrete, non-continuous spectra are an observable result of the physics of atoms. Unlike a continuous spectrum source, which can radiate at an arbitrary frequency (just change the effective temperature), the electron clouds surrounding the nuclei of atoms have very specific energies dictated by quantum mechanics. Each element on the periodic table has its own set of possible energy levels. Electrons tend to settle to the ground state, so an excited atom with an electron in a higher energy level will emit a wave of light with that exact energy to allow the electron to fall into the ground state. This energy corresponds to a specific color, or wavelength, of light, so we see a bright line at that exact wavelength. We can observe emission lines in spectra from comets, nebula and certain types of stars.
[NMSU, N. Vogt]

Absorption spectrum
If light from a stellar core with a continuous spectrum encounters an atom, the wavelengths corresponding to possible energy transitions within the atom will be absorbed. The light may be re-emitted later, but as it will be re-emitted in a random direction the spectrum along the line of sight will be preferentially lacking in flux at the wavelength which corresponds to the energy transitions within the atom. We can observe absorption features in spectra from regions in space where a cooler gas lies between us and a hotter source, from stars, from planets with atmospheres, and from galaxies.
[NMSU, N. Vogt]

Solar spectrum
This detailed spectrum shows the spectrum of the Sun, a nearly continuous function broken by absorption features. Can you identify any of the species present in the solar atmosphere, from the wavelengths or colours of the absorption lines? What elements do you expect to feature prominently in the solar spectrum?


The diagram below shows how one could observe a continuum spectrum, and emission spectrum, or an absorption spectrum from different positions around a continuum source partially shrouded by a cool gas cloud.

[NMSU, N. Vogt]