Here's why:
* Light is a wave: Starlight, like all light, travels in waves. Different colors of light have different wavelengths.
* Refraction: When light passes from one medium to another (like air to glass), it bends. This bending is called refraction. The amount of bending depends on the wavelength of the light.
* Prisms and refraction: A prism is a triangular piece of glass or other transparent material. As light enters the prism, each color of light is refracted at a slightly different angle because of its different wavelength. This separation of colors is what creates the spectrum.
In short: A prism uses refraction to separate the different wavelengths of light in starlight, making the rainbow of colors visible.