The word spectrum was first used in optics to define the band of multiple colours that is produced when light passes and splits across the glass prism or an air drop. In generality, spectrum can be defined as a range of any kind of thing. Therefore, in physics and chemistry, spectrum is defined as a range of waves (light, radio, sound or electromagnetic) within a particular frequency.
The rainbow shows an optical spectrum. When white light splits across the prism or an air drop, the resulting spectrum is arranged according to the wavelengths of the wave. That is to say, red colour is produced by the longest wavelength and violet colour is produced by the shortest wavelength. The other colours from – indigo, blue, green, yellow and orange have wavelength between violet and red in an increasing order. This splitting of light is called dispersion, and since there is no gap between red to violet, it is also called continuous spectrum. But in practical cases, the spectrum is not continuous. Even the rainbow formed after the rain has gaps. The light from the sun has gaps.
Human light is designed as such it can only view the the waves that falls within some particular range of wavelength or frequency. Light waves are visible to the human eye. There are many waves that are not visible to human eyes like extremely low frequency waves, radio waves, microwaves, infrared waves, ultraviolet rays, X-rays, gamma rays. The spectrum that includes all these ways and the light rays is called electromagnetic spectrum. Finding an object that emits the electromagnetic spectrum that gives all the waves (that is continuous electromagnetic spectrum) is impossible.
When sun gives light, the light given by it is not continuous spectrum. When we pass sunlight through a spectrometer (a device that splits light into multiple wavelengths), we find gaps in sunlight. These gaps in the sunlight are called absorption spectrum. Sun contains Hydrogen and Helium molecules. Therefore, when sunlight has waves that match the energy of these molecules, these molecules absorbs such waves. Therefore, a gap is created in the continuous spectrum of sun. If we analyse the spectrum of sun, by looking at the wavelengths which are missing, we can analyse which all elements are present in sun, since every element has a different combination of absorption lines. Emission spectrum is the opposite of absorption spectrum. Only waves which have been emitted by elements are present.