sunlight hit my cd and a rainbow was produced. can anyone tell me why ?
refraction happen when the cd reflect the light
It is not refraction which causes the rainbow, it is diffraction. The CD is a spiral of tiny pits which encode the digital information. The spiral forms a set of roughly concentric closely-spaced lines on the disc's metallic inner layer. These lines act as a diffraction grating, and spread the light out into its constituent colors.
You can google "CD diffraction" and find all the info you'd ever want. :)
Separate names with a comma.