The speed of electromagnetic waves is determined by the optical density of the medium. The speed of light in a medium is determined by the medium's qualities.
The refractive index is defined as the ratio of light's speed in a vacuum to its speed in a certain medium and is often referred to as the refraction index or index of refraction. When light travels in a medium other than a vacuum, the atoms of that medium absorb and re-emit light particles, reducing the speed of light. The refractive index is the ratio of the speed of light in a medium to the speed of light in a vacuum.