This can be useful because colour can tell us a lot about the physics of the object. For example, you can measure the temperature of a star from its colour. By looking at a spectrum of an object you can also work out what elements are in the star. This is because different element block out light from stars at certain wavelengths or colours.
Spectrographs are complicated pieces of equipment. They are made of mirrors, filters, lamps and CCD cameras. But the most important piece of a spectrograph is the grating or prism. These are used to split white light up into the different colours. Prisms have been used since the 1600s to split light. As light hits a prism it is bent, or refracted. The different colours all bend different amounts, red the least and blue the most. Modern telescopes tend to use gratings instead of prisms. These split the light by reflecting it rather than refracting it. They are more efficient as they don't absorb any of the light. They can also reflect UV light which is absorbed by prisms completely.