Why do atoms display spectra?

Electrons in an atom are excited; they move to higher energy levels, when they fall to lower energy levels they emit the difference in energy between the higher state and the lower state. Some of this energy is in the visible spectrum and we can see it with our eyes but much of it is in the x-ray, ultra-violet, or infrared and we need special instruments to observe that.