Why does sun bathing tan?

Tanning is a sort of natural protection mechanism provided by nature to the human skin. It involves an increase in the production of the pigment melanin which helps protect the skin against the dangerous effects of too much ultraviolet radiation from the sun.

The outermost layer of the skin contains cells called melanocytes that produce the pigment melanin. When the skin is exposed to the sun, the melanocytes get stimulated by the ultraviolet rays and produce more of melanin. This acts as a filter to block ultraviolet rays from penetrating the skin. The increased production of the brown-coloured melanin gives a darker colour to the skin, which appears as suntan.