The classic rainbow is a single, bright, colored arc. Red is the outermost color of this arc, and violet is always the innermost color.
On occasion, you may have seen two rainbows at once. The lower rainbow is the primary rainbow and the higher, fainter, colored arc is the secondary rainbow. The color sequence of the secondary rainbow is opposite to the primary; red is on the inside of the arc and violet on the outside.
When sunlight passes through a triangular glass prism, it separates into the colors of the rainbow. This separation happens because different colors bend, or refract, by different amounts. The shortest (blue and violet) wavelengths refract the most; red light refracts the least.
The separation of colors is referred to as dispersion. Not only prisms but also water drops and ice crystals can cause dispersion. To form a rainbow you need large drops of water, the sun at your back and at the correct angle.
Raindrops act as prisms, bending and reflecting the sunlight that falls on them, just like a crystal hung in a sunny window.
As light enters water, the path it takes changes. How much the direction changes is a function of the color of the light.
You probably noticed that a smooth water surface can act like a mirror and reflect light. If the light beam entering the raindrop reaches the back of the drop at a certain angle, it undergoes a reflection and heads back toward the sun. As the light exits the raindrop and re-enters the air, its path bends an amount that again depends on the color. This bending of the light as it enters and leaves the drop disperses the light of the sun into its spectrum of colors that form the rainbow.
Sometimes the light reflects twice off the back of the raindrop; this leads to the secondary rainbow. The second reflection causes the order of the colors in the bow to reverse.