Most of the damage from the sun comes from UV (ultra violet) rays. UV light is split into UVA, UVB and UVC rays. UVC rays do not normally affect the skin as they are completely filtered out by the atmosphere before they reach us.
UVB penetrates into the outer layer of the skin and damages the cells causing the skin to become inflamed or sunburnt. UVA rays penetrate more deeply causing direct damage to supporting tissues leading to ageing effects. Both types of rays are attributed to causing skin cancers of various types.