A prism or diffraction grating attached to a telescope will split up the light from a star into the different wavelengths just like a rainbow . The spectra of the stars illustrated here show some typical examples.
Dark lines in the spectrum are caused by elements in the outer gases of the star absorbing light from the core of the star at wavelengths characteristic of particular atoms. Atomic Hydrogen for example absorbs light at wavelengths named H(Alpha), H(Beta) and H(Gamma) etc. and these are seen as absorption peaks in a graphical representation of the spectrum image.
The spectrum of Vega is typical of stars which appear to be blue/white in colour to the naked eye. It shows a clear sequence of lines which result from electron transitions between specific energy levels of atomic hydrogen ( the so called Balmer series ). Similarly for Sirius shown below.
Bright lines in the spectrum of Gamma in the constellation of Cassiopeiae ( the middle star of the W asterism ) are emission lines from a disc of matter ejected by rapid rotation. This was one of the class Be stars studied by Margaret Burbidge in 1940 when she was working on her Ph.D. thesis at UCL.
Broad bands in the spectrum of the orange/red coloured star Betelgeuse indicate a more advanced stage of star evolution and come from molecular fragments of carbon, nitrogen and oxygen.
Kevin Worvill ( From the CNAAG display at the Chipping Norton Theatre in 2016 )