These can absorb or scatter the incoming sunlight. In absorption the sunlight disappears. The energy is taken from the sunlight by the absorbing material. In scattering the sunlight changes direction, like a tennis ball after bouncing off a wall, or the floor. When sunlight enters the atmosphere the shorter wavelength components are the most affected.
Blue light is much more likely to scatter than either yellow or red light.
Scattering by objects much smaller than the wavelength itself is called Rayleigh scattering. Colors Blue light is Rayleigh scattered out of the Sun's original direction and into another. After a series of scatters the blue light ends up in all directions. So the sky is blue in all directions and bright enough to obscure the stars. Since a lot of the blue light is no longer in the original direction, the remaining light becomes more yellow.