Melanin is the dark pigment of the skin. It is produced by a special set of cells called melanocytes in the skin. Melanin is transported to the outermost cells of the skin from the melanocytes and forms an umbrella-like structure within these skin cells. Melanin absorbs ultraviolet (UV) rays of the sun and protects the deeper layers of the skin from the harmful effects of UV rays. Thus, Melanin prevents skin cancer.
Depending on the type and duration of sun exposure, the skin develops different types of tans- each one takes a different amount of time to go away. The types are-Â
Immediate Pigment darkening

Appears immediately after sun exposure. It tends to resolve usually within 2 hours.Â

Cause- UV A rays
UVA causes photo-oxidation of the existing melanin and causes it to further darken. Also, There is a redistribution of the melanin from a deeper site to a more superficial position causing the skin to appear darker. There is no change in the amount of melanin in the skin.
Persistent pigment darkening
This type of tanning is similar to immediate pigment darkening but persists for upto 24 hours. It is seen when a higher amount of UVA is incident on the skin.
Delayed Tanning
Appears 3 days after sun exposure. It persists for several weeks. The tanning also affects skin that hasn’t been directly exposed to direct sunlight. Repeated prolonged sun exposure will result in the eventual thickening of the skin as well.
Cause?Â
In the light skinned- UVB rays
In the Dark skinned- UVB rays, UVA rays
What’s happening in the skin?Â
An increase in the amount of both melanocytes and melanin occurs after UV-B exposure. UV-B causes an increase in the amount of melanocyte stimulating hormone (MSH) which causes darkening of skin not exposed to direct sunlight.Â
UV-B causes a thickening of the skin itself. this offers a much better protection against the ill effects of sunlight. This effect reverses over several weeks in the absence of UV exposure.
Read more about tanning here.