Why does the skin get tanned in the sun?

In the summers, our skin is often exposed to UV radiation from strong sun that can damage the skin. A pigment, called melanin, is produced in the skin to protect against the harmful radiations from the sun. The more this pigment is produced, the darker, i.e., more tanned, is the skin and the higher is the protection against sunburn. That is why; many light-skinned people get sunburnt very quickly. Sunburn always means damage to the skin. Even when the skin has apparently recovered from the burn, it remains damaged from inside and there is always a high risk of getting skin cancer later.