It is so because melanin gives a pigment to the skin, whereas carotene gives a pigment to hair. When we are exposed to sunlight, our skin produces more of this pigment to protect itself. As a result, the skin darkens. Hair, however, contains some of its natural pigments but remains relatively blonde in contrast to tanned skin. Therefore, in the sun, the skin turns darker, but the hue of the hair remains the same density.