The color of the atmosphere is primarily determined by scattering of sunlight by molecules and particles in the air. The sky appears blue during the day due to Rayleigh scattering, which preferentially scatters shorter (blue) wavelengths of light. At sunrise and sunset, the shorter wavelengths are scattered out of the direct line of sight, resulting in longer wavelengths (red and orange) being scattered back to the observer, giving the sky a reddish hue. The sky can also appear purple or green under certain conditions, such as when the atmosphere is filled with dust or other particles.