Like most features, hair colour is caused by a combination of your genes and your environment. We know that natural hair colour depends on the amounts of two substances in the hair: eumelanin and pheomelanin. Blondes have a small amount of eumelanin; brown haired people have a higher level and black haired people have the most. he amounts of these pigments depend on the genes you inherit from your parents, but they can also be changed by your environment eg if you spend a long time in the sun, your hair will bleach.
Three factors contribute to skin color: 1) the amount and kind (yellow, reddish brown, or black) of melanin in the epidermis; 2) the amount of carotene (yellow) in the epidermis and subcutaneous tissue; and 3) the amount of oxygen bound to hemoglobin (red blood cell pigment) in the dermal blood cells. Skin color is genetically determined, for the most part.