How does the skin tan?

An individual’s skin color is a result of a combination of factors: skin circulation, the color of the corneal layer and the amount of pigment in the skin. The most important of these is the pigment melanin, which can range in color from buff to black. The pigment melanin is formed by special pigment cells called melanocytes. These cells are found in the lowest basal layer alongside the epidermis cells.
The pigment cells produce melanin, some of which is delivered to other cells in the form of tiny grains. It is only through the process of cell regeneration in the basal layer that the grains of melanin are carried by neighboring cells and move up in the skin. Through the normal process of regeneration of the epidermis, the grains of melanin reach the surface corneal layer, where they are shed with other horny skin cells.

How is melanin formed in cells?
The colorless precursor of melanin is the amino acid tyrosine. Following a series of changes, catalyzed by the cupreous skin enzyme tyrosinase and oxygen, this amino acid becomes melanin. However, this change is only activated and carried out by exposure to sunlight. Although pigment production does not depend on the number of pigment cells, it does however depend on the rate at which the pigment cells metabolize. Individuals with fair and dark skin do not differ in the number of pigment-forming cells they have; there is however a large difference in the rate of metabolism and activity of pigment cells.