I think that you are reffering to white light dispersion.
To see how it happens, you need to do this experiment:
Place a glass triangular prism into a dark room. Put this prism on a table or on the floor and place an white paper behind the prism. Place a source of white light in front of the prism and you'll notice that if a ray of light hits one side of the prism, you'll get a dispersed light on the other side of the prism.
The dispersed white light will have different colors that you'll be able to see on the piece of white paper. The dispersed light is broken into 7 colors: Violet,Indigo,Blue,Green,Yellow.,Orange,Red or VIBGYOR, the colors of the Rainbow.