The answer to this question is simply wavelength.
The electromagnetic spectrum is a continuous spectrum of many waves which all have a different wavelength or frequency
best way to see this is if we pass white light through a prism. The prism splits
all the different waves into their colors like a rainbow does.
The only difference between red light and blue or green light is the wavelength of the wave. Red light has a longer wavelength than green, and green is longer than blue, etc.
Wavelength is also related to frequency and energy. Short waves have higher energy than do longer waves do. Frequency can be thought of as the number of waves in a given time period, or how compact the wave crests are. As you can see, violet colored light has a higher frequency than green because its wavelength is shorter.