Fascinating Facts: The Sun is White, Not Yellow
For the graphics people out there, the exact color of the sun is #fff5f2. The reason the Sun looks yellow to people is that our atmosphere scatters light from the Sun; so the perceived color of the sun changes. This same scattering effect is why the sky looks blue in the day time instead of black, like at night.
Specifically, what is going on is the Earth’s atmosphere scatters light in the blue and violet wavelength range, so the remaining wavelengths of light appear yellow. This same effect is why the sky will also often appear yellow when the Sun is disappearing over the horizon, as well as why the sky and Sun can appear more red at times during this phase of the day.
As the sun is setting, more of the shorter wavelength blue is being scattered because of the decreased angle of the sun relative to you; thus the light has to pass through more atmosphere to get to you. This increased diffusion results in less of the blue wavelength being visible to you and thus what remains appears yellow. Similarly, if it is dusty or there are a lot of other larger particles in the air, this will filter out larger wavelengths, resulting in a red sky and red sun.