Light is made-up of different colours. Each colour travels at its own speed inside a prism.Due to this different colours of light bend through different angles with respect to the incident ray, as they pass through a prism. The red light bends the least while the violet the most. Thus, the rays of each colour emerge along different paths and thus - become distinct. It is the band of distinct colours that we see in a spectrum.
The diagram is as shown: